Ejemplo n.º 1
0
        private IntPtr ManagedAlloc(int size, bool zeroMemory = true)
        {
            var memory = MemoryManagement.Malloc(new IntPtr(size));

            if (zeroMemory)
            {
                MemoryManagement.MemSet(memory, 0, new IntPtr(size));
            }

            if (memory == IntPtr.Zero)
            {
                throw new Exception("Out of memory.");
            }

            return(memory);
        }