public override void *Allocate(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.HeapAlloc(_HeapPointer, flags, (uint)(elementCount * elementSize)); if (memory == null) { throw new OutOfMemoryException(); } return(memory); }