Allocator of small blocks, with a FreeStore for each multiple of 16 bytes up to 2048.
More...
#include <fixedsizealloc.h>
|
| | FixedSizeAlloc () |
| | Construct an allocator with no stores yet.
|
| void * | Alloc (int nSize, int nUnused) |
| | Hand out a block from the store of its size, creating the store on first use.
|
| void | Free (void *pBlock, int nSize) |
| | Return a block to the store of its size.
|
| void | Report (PrnStream &stream) |
| | Write the use of each store and the bytes their free nodes take.
|
| | FixedSizeAlloc (int allocSizeWords) |
| | Create an empty allocator.
|
| void * | Alloc () |
| | Take a node, refilling the free list from a new chunk when it is empty.
|
| void | Free (void *mem) |
| | Return a node to the free list.
|
| void | GetStats (int *nodeSize, int *numAllocs, int *maxAllocs, int *capacity, int *wasted) |
| | Report the allocator's use.
|
|
| static int | StoreIndex (int nSize) |
| | Report the store a size of block takes.
|
| static int | StoreNodeWords (int nIndex) |
| | Report the node size of a store.
|
|
| static constexpr int | kNumStores = 128 |
| | The node sizes, one for each 16 bytes.
|
Allocator of small blocks, with a FreeStore for each multiple of 16 bytes up to 2048.
Free list of equal-sized nodes carved from pool chunks.
The class is not polymorphic. The name comes from the tag of its stores. PoolAlloc() hands out its blocks.
The object is 0x18 bytes. The name comes from the allocation name its owner passes.
◆ FixedSizeAlloc() [1/2]
| FixedSizeAlloc::FixedSizeAlloc |
( |
| ) |
|
Construct an allocator with no stores yet.
- Ghidra address:
- NTSC-U/C: 0x0029de20
- Ghidra address:
- PAL: 0x002a7ae8
◆ FixedSizeAlloc() [2/2]
| FixedSizeAlloc::FixedSizeAlloc |
( |
int | allocSizeWords | ) |
|
|
explicit |
Create an empty allocator.
- Parameters
-
| allocSizeWords | The node size in words. |
- Ghidra address:
- 0x10011880
◆ Alloc() [1/2]
| void * FixedSizeAlloc::Alloc |
( |
int | nSize, |
|
|
int | nUnused ) |
Hand out a block from the store of its size, creating the store on first use.
- Parameters
-
| nSize | The size of the block in bytes. |
| nUnused | Not used. |
- Returns
- The block.
- Ghidra address:
- NTSC-U/C: 0x0029de58
- Ghidra address:
- PAL: 0x002a7b20
◆ Free() [1/2]
| void FixedSizeAlloc::Free |
( |
void * | pBlock, |
|
|
int | nSize ) |
Return a block to the store of its size.
- Parameters
-
| pBlock | The block. |
| nSize | The size given to Alloc(). |
- Ghidra address:
- NTSC-U/C: 0x0029ded8
- Ghidra address:
- PAL: 0x002a7ba0
◆ Report()
| void FixedSizeAlloc::Report |
( |
PrnStream & | stream | ) |
|
Write the use of each store and the bytes their free nodes take.
- Parameters
-
| stream | The stream to write to. |
- Ghidra address:
- NTSC-U/C: 0x0029df28
- Ghidra address:
- PAL: 0x002a7bf0
◆ StoreIndex()
| int FixedSizeAlloc::StoreIndex |
( |
int | nSize | ) |
|
|
static |
Report the store a size of block takes.
- Parameters
-
- Returns
- The index of the store.
- Ghidra address:
- NTSC-U/C: 0x0029db50
- Ghidra address:
- PAL: 0x002a7818
◆ StoreNodeWords()
| int FixedSizeAlloc::StoreNodeWords |
( |
int | nIndex | ) |
|
|
static |
Report the node size of a store.
- Parameters
-
| nIndex | The index of the store. |
- Returns
- The node size in words.
- Ghidra address:
- NTSC-U/C: 0x0029db60
- Ghidra address:
- PAL: 0x002a7828
◆ Alloc() [2/2]
| void * FixedSizeAlloc::Alloc |
( |
| ) |
|
Take a node, refilling the free list from a new chunk when it is empty.
- Returns
- The node.
- Ghidra address:
- 0x100118d0
◆ Free() [2/2]
| void FixedSizeAlloc::Free |
( |
void * | mem | ) |
|
Return a node to the free list.
- Parameters
-
- Ghidra address:
- 0x10011900
◆ GetStats()
| void FixedSizeAlloc::GetStats |
( |
int * | nodeSize, |
|
|
int * | numAllocs, |
|
|
int * | maxAllocs, |
|
|
int * | capacity, |
|
|
int * | wasted ) |
Report the allocator's use.
- Parameters
-
| nodeSize | Receives the node size in bytes. |
| numAllocs | Receives the nodes in use. |
| maxAllocs | Receives the most nodes in use at once. |
| capacity | Receives the nodes in all chunks. |
| wasted | Receives the bytes in unused nodes. |
- Ghidra address:
- 0x100119a0
◆ kNumStores
| int FixedSizeAlloc::kNumStores = 128 |
|
staticconstexpr |
The node sizes, one for each 16 bytes.
The documentation for this class was generated from the following files: