128 this->
nodes.Resize(maxNumAllocs);
159 for (
uint i = 0; i < this->
nodes.Size(); i++)
187 uint alignedSize =
size + alignment - 1;
194 uint bin = 0xFFFFFFFF;
202 if (bin == 0xFFFFFFFF)
208 if (bucket == 0xFFFFFFFF)
229 node.
size = alignedSize;
254 uint remainder = totalSize - node.
size;
324 this->
nodes[leftNode].blockNext = mergedNode;
325 this->
nodes[mergedNode].blockPrev = leftNode;
330 this->
nodes[rightNode].blockPrev = mergedNode;
331 this->
nodes[mergedNode].blockNext = rightNode;
361 newNode.
binNext = headNodeIndex;
372 headNode.
binPrev = newNodeIndex;
435 _BitScanReverse(&count, size);
437 int count = 31 - __builtin_clz(size);
455inline RangeAllocator::BinIndex
464 if ((~mask &
size) != 0)
Implements helper functions for checking bits.
Definition rangeallocator.h:39
~RangeAllocator()
Destructor.
Definition rangeallocator.h:138
RangeAllocator()
Default constructor.
Definition rangeallocator.h:115
void Clear()
Clear allocator.
Definition rangeallocator.h:146
uint size
Definition rangeallocator.h:99
Util::Array< RangeAllocatorNode > nodes
Definition rangeallocator.h:107
void RemoveNode(uint nodeIndex)
Remove node from bin.
Definition rangeallocator.h:383
uint InsertNode(uint size, uint offset)
Insert node at bin location, return node index.
Definition rangeallocator.h:339
uint bucketUsageMask
Definition rangeallocator.h:103
bool Empty()
Empty.
Definition rangeallocator.h:175
uint freeNodeIterator
Definition rangeallocator.h:101
static BinIndex IndexFromSize(uint size, bool round=false)
Get bin index from size.
Definition rangeallocator.h:456
RangeAllocation Alloc(uint size, uint alignment=1)
Allocate memory.
Definition rangeallocator.h:184
uint binMasks[NUM_BUCKETS]
Definition rangeallocator.h:104
uint freeStorage
Definition rangeallocator.h:100
Util::Array< uint > freeNodes
Definition rangeallocator.h:108
void Dealloc(const RangeAllocation &allocation)
Deallocate memory.
Definition rangeallocator.h:280
uint binHeads[NUM_BUCKETS *NUM_BINS_PER_BUCKET]
Definition rangeallocator.h:105
Nebula's dynamic array class.
Definition array.h:60
void Resize(SizeT num)
Set size. Grows array if num is greater than capacity. Calls destroy on all objects at index > num!
Definition array.h:1606
const SizeT Size() const
get number of elements in array
Definition array.h:880
#define n_assert(exp)
Definition debug.h:50
__forceinline unsigned int align(unsigned int alignant, unsigned int alignment)
Definition scalar.h:722
Allocates memory using the TLSF method (http://www.gii.upv.es/tlsf/files/ecrts04_tlsf....
Definition arenaallocator.h:31
static constexpr uint NUM_BINS_PER_BUCKET
Definition rangeallocator.h:36
static constexpr uint NUM_BUCKETS
Definition rangeallocator.h:35
uint BinFromSize(uint size, uint bucket)
Get bin from index.
Definition rangeallocator.h:446
uint BucketFromSize(uint size)
Get bucket from index.
Definition rangeallocator.h:431
uint Lsb(uint value, byte bit)
Definition bit.h:229
uint FirstOne(uint value)
Definition bit.h:169
Definition rangeallocator.h:27
uint offset
Definition rangeallocator.h:28
static constexpr uint OOM
Definition rangeallocator.h:32
uint size
Definition rangeallocator.h:29
uint node
Definition rangeallocator.h:30
Definition rangeallocator.h:66
uint offset
Definition rangeallocator.h:78
bool resident
Definition rangeallocator.h:76
static constexpr uint END
Definition rangeallocator.h:80
uint blockNext
Definition rangeallocator.h:82
uint size
Definition rangeallocator.h:77
RangeAllocatorNode()
Definition rangeallocator.h:67
uint blockPrev
Definition rangeallocator.h:82
uint binPrev
Definition rangeallocator.h:81
uint binNext
Definition rangeallocator.h:81
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
uint16_t uint16
Definition types.h:40
Definition rangeallocator.h:86
uint16 index
Definition rangeallocator.h:93
uint16 bucket
Definition rangeallocator.h:91
BinIndex()
Definition rangeallocator.h:87
uint16 bin
Definition rangeallocator.h:90