wavelength 1.0.0
Loading...
Searching...
No Matches
FixedSizeAlloc Class Reference

Allocator of small blocks, with a FreeStore for each multiple of 16 bytes up to 2048. More...

#include <fixedsizealloc.h>

Public Member Functions

 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 Public Member Functions

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 Public Attributes

static constexpr int kNumStores = 128
 The node sizes, one for each 16 bytes.

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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
allocSizeWordsThe node size in words.
Ghidra address:
0x10011880

Member Function Documentation

◆ 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
nSizeThe size of the block in bytes.
nUnusedNot 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
pBlockThe block.
nSizeThe 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
streamThe 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
nSizeThe size in bytes.
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
nIndexThe 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
memThe node.
Ghidra address:
0x10011900

◆ GetStats()

void FixedSizeAlloc::GetStats ( int * nodeSize,
int * numAllocs,
int * maxAllocs,
int * capacity,
int * wasted )

Report the allocator's use.

Parameters
nodeSizeReceives the node size in bytes.
numAllocsReceives the nodes in use.
maxAllocsReceives the most nodes in use at once.
capacityReceives the nodes in all chunks.
wastedReceives the bytes in unused nodes.
Ghidra address:
0x100119a0

Member Data Documentation

◆ 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: