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

Free list of nodes of one size, grown a chunk of nodes at a time from the hunks of the pool. More...

#include <freestore.h>

Classes

struct  Node
 A free node, which starts with the link to the next one. More...

Public Member Functions

 FreeStore (int nNodeWords)
 Construct an empty store.
void * Alloc ()
 Hand out a node, growing the store when none is free.
void Free (void *pNode)
 Return a node.
void Grow ()
 Add a chunk of mNodesPerChunk free nodes.
void * AllocChunk (int nBytes)
 Take a chunk of nodes from the hunks of the pool.
void GetStats (int *pnNodeBytes, int *pnAllocs, int *pnMaxAllocs, int *pnCapacity, int *pnWasted)
 Report the use of the store.

Static Public Member Functions

static void * operator new (size_t nSize)
 Allocate a store from the pool heaps.
static void Configure (DataArray *pConfig)
 Read the sizes of the pool's hunks from the pool block of the mem configuration.
static void * AllocHunk (int nBytes)
 Carve bytes from the current hunk of the pool, allocating a new hunk when they do not fit.

Static Public Attributes

static int sHunkBytes
 The bytes AllocHunk() has handed out.

Detailed Description

Free list of nodes of one size, grown a chunk of nodes at a time from the hunks of the pool.

The class is not polymorphic. The name is inferred. FixedSizeAlloc keeps one for each node size.

Constructor & Destructor Documentation

◆ FreeStore()

FreeStore::FreeStore ( int nNodeWords)
explicit

Construct an empty store.

Parameters
nNodeWordsThe size of each node in words.
Ghidra address:
NTSC-U/C: 0x0029dc78
Ghidra address:
PAL: 0x002a7940

Member Function Documentation

◆ operator new()

void * FreeStore::operator new ( size_t nSize)
inlinestatic

Allocate a store from the pool heaps.

Parameters
nSizeThe size of the store.
Returns
The block.

◆ Alloc()

void * FreeStore::Alloc ( )

Hand out a node, growing the store when none is free.

Returns
The node.
Ghidra address:
NTSC-U/C: 0x0029dca0
Ghidra address:
PAL: 0x002a7968

◆ Free()

void FreeStore::Free ( void * pNode)

Return a node.

Parameters
pNodeThe node.
Ghidra address:
NTSC-U/C: 0x0029dd00
Ghidra address:
PAL: 0x002a79c8

◆ Grow()

void FreeStore::Grow ( )

Add a chunk of mNodesPerChunk free nodes.

Ghidra address:
NTSC-U/C: 0x0029dd20
Ghidra address:
PAL: 0x002a79e8

◆ AllocChunk()

void * FreeStore::AllocChunk ( int nBytes)

Take a chunk of nodes from the hunks of the pool.

Parameters
nBytesThe size of the chunk.
Returns
The chunk.
Ghidra address:
NTSC-U/C: 0x0029ddb0
Ghidra address:
PAL: 0x002a7a78

◆ GetStats()

void FreeStore::GetStats ( int * pnNodeBytes,
int * pnAllocs,
int * pnMaxAllocs,
int * pnCapacity,
int * pnWasted )

Report the use of the store.

Parameters
pnNodeBytesReceives the size of each node in bytes.
pnAllocsReceives the nodes handed out.
pnMaxAllocsReceives the most nodes handed out at one time.
pnCapacityReceives the nodes of every chunk.
pnWastedReceives the bytes of the free nodes.
Ghidra address:
NTSC-U/C: 0x0029ddd0
Ghidra address:
PAL: 0x002a7a98

◆ Configure()

void FreeStore::Configure ( DataArray * pConfig)
static

Read the sizes of the pool's hunks from the pool block of the mem configuration.

The first hunk takes big_hunk bytes and every later one small_hunk bytes.

Parameters
pConfigThe pool block.
Ghidra address:
NTSC-U/C: 0x0029db70
Ghidra address:
PAL: 0x002a7838

◆ AllocHunk()

void * FreeStore::AllocHunk ( int nBytes)
static

Carve bytes from the current hunk of the pool, allocating a new hunk when they do not fit.

Parameters
nBytesThe bytes.
Returns
The bytes.
Ghidra address:
NTSC-U/C: 0x0029dbc8
Ghidra address:
PAL: 0x002a7890

Member Data Documentation

◆ sHunkBytes

int FreeStore::sHunkBytes
static

The bytes AllocHunk() has handed out.

Ghidra address:
NTSC-U/C: 0x003b2420
Ghidra address:
PAL: 0x004312e0

The documentation for this class was generated from the following file: