Example #1
0
            public int Try(ref Block block)
            {
                block.Range.Allocator = this;
                var error = AllocatorManager.Try(ref block);

                return(error);
            }
Example #2
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);
                }
Example #3
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);
        }