wavelength 1.0.0
Loading...
Searching...
No Matches
FixedSizeAlloc.h
Go to the documentation of this file.
1#pragma once
2
7
13class FixedSizeAlloc {
14public:
21 explicit FixedSizeAlloc(int allocSizeWords);
22
29 void *Alloc();
30
37 void Free(void *mem);
38
49 void GetStats(int *nodeSize, int *numAllocs, int *maxAllocs, int *capacity, int *wasted);
50
51private:
57 void Refill();
58
66 void *RawAlloc(int bytes);
67
68 int mAllocSizeWords;
69 int mNumAllocs;
70 int mMaxAllocs;
71 int mNumChunks;
72 FixedSizeNode *mFreeList;
73 int mNodesPerChunk;
74};
Allocator of small blocks, with a FreeStore for each multiple of 16 bytes up to 2048.
Definition fixedsizealloc.h:12
FixedSizeAlloc(int allocSizeWords)
Create an empty allocator.
void Free(void *mem)
Return a node to the free list.
void * Alloc()
Take a node, refilling the free list from a new chunk when it is empty.
void GetStats(int *nodeSize, int *numAllocs, int *maxAllocs, int *capacity, int *wasted)
Report the allocator's use.
Free node of a FixedSizeAlloc.
Definition FixedSizeAlloc.h:4
FixedSizeNode * mNext
Definition FixedSizeAlloc.h:5