public override void Free(void *pointer) { if (Kernel32HeapMemory.HeapFree(_HeapPointer, HeapMemoryFlags.NONE, pointer) == false) { throw new InvalidOperationException("Invalid pointer"); } }
public int SizeOf(void *pointer) { if (pointer == null) { throw new ArgumentException("Invalid pointer"); } return((int)Kernel32HeapMemory.HeapSize(_HeapPointer, HeapMemoryFlags.NONE, pointer)); }
public override void *Reallocate(void *pointer, int elementCount, int elementSize = 1, bool initMemory = true) { if (elementCount <= 0) { throw new ArgumentException(elementCount.ToString(), nameof(elementCount)); } if (elementSize <= 0) { throw new ArgumentException(elementSize.ToString(), nameof(elementSize)); } HeapMemoryFlags flags = initMemory ? HeapMemoryFlags.HEAP_ZERO_MEMORY : HeapMemoryFlags.NONE; void * memory = Kernel32HeapMemory.HeapReAlloc(_HeapPointer, flags, pointer, (uint)(elementCount * elementSize)); if (memory == null) { throw new OutOfMemoryException(); } return(memory); }