Files
ntwain/src/NTwain/IMemoryManager.cs
2018-11-13 20:04:05 -05:00

40 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NTwain
{
/// <summary>
/// Interface that provides the correct methods for managing memory on data exchanged with TWAIN sources.
/// </summary>
public interface IMemoryManager
{
/// <summary>
/// Function to allocate memory. Calls to this must be coupled with <see cref="Free"/> later.
/// </summary>
/// <param name="size">The size in bytes.</param>
/// <returns>Handle to the allocated memory.</returns>
IntPtr Allocate(uint size);
/// <summary>
/// Function to free memory.
/// </summary>
/// <param name="handle">The handle from <see cref="Allocate"/>.</param>
void Free(IntPtr handle);
/// <summary>
/// Function to lock some memory. Calls to this must be coupled with <see cref="Unlock"/> later.
/// </summary>
/// <param name="handle">The handle to allocated memory.</param>
/// <returns>Handle to the lock.</returns>
IntPtr Lock(IntPtr handle);
/// <summary>
/// Function to unlock a previously locked memory region.
/// </summary>
/// <param name="handle">The same handle passed <see cref="Lock"/>.</param>
void Unlock(IntPtr handle);
}
}