예제 #1
0
                static void *CustomResize(void *oldPointer, long oldCount, long newCount, Allocator allocator, long size, int align)
                {
                    AllocatorManager.Block block = default;
                    block.Range.Allocator = new AllocatorManager.AllocatorHandle {
                        Index = (ushort)allocator
                    };
                    block.Range.Items    = (int)newCount;
                    block.Range.Pointer  = (IntPtr)oldPointer;
                    block.BytesPerItem   = (int)size;
                    block.Alignment      = align;
                    block.AllocatedItems = (int)oldCount;
                    var error = AllocatorManager.Try(ref block);

                    CheckFailedToAllocate(error);
                    return((void *)block.Range.Pointer);
                }
예제 #2
0
        public unsafe int Try(ref AllocatorManager.Block block)
        {
            var temp = block.Range.Allocator;

            block.Range.Allocator = m_parent;
            var error = AllocatorManager.Try(ref block);

            block.Range.Allocator = temp;
            if (error != 0)
            {
                return(error);
            }
            if (block.Range.Pointer != IntPtr.Zero)                                           // if we allocated or reallocated...
            {
                UnsafeUtility.MemSet((void *)block.Range.Pointer, m_clearValue, block.Bytes); // clear to a value.
            }
            return(0);
        }
 public static unsafe int Try(IntPtr state, ref AllocatorManager.Block block)
 {
     return(((ClearToValueAllocator *)state)->Try(ref block));
 }