Beispiel #1
0
        public override unsafe 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));
            }

            if (pointer == null)
            {
                throw new ArgumentException("Pointer is null");
            }

            int            bytesCount = elementCount * elementSize;
            CppMemoryFlags flags      = initMemory ? CppMemoryFlags.ZERO_MEMORY : CppMemoryFlags.UNITIALIZATED;
            void *         block      = CppMemory.Realloc(pointer, (uint)bytesCount, flags);

            if (block == null)
            {
                throw new OutOfMemoryException();
            }

            return(block);
        }
 public static extern void *Realloc(void *pointer, uint size, CppMemoryFlags flags);
 public static extern void *Malloc(uint size, CppMemoryFlags flags);