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

Pool of equal blocks carved from a region, each free block linking to the next. More...

#include <blockpool.h>

Classes

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

Public Member Functions

void Init (int nBlockSize, int nNumBlocks, void *pMemory)
 Take over a region as a chain of free blocks.
void * Alloc ()
 Hand out the first free block.
void Free (void *pBlock)
 Return a block to the head of the chain.

Detailed Description

Pool of equal blocks carved from a region, each free block linking to the next.

The class is not polymorphic. The name is inferred. The memory tracker takes its AllocInfo records from one.

Member Function Documentation

◆ Init()

void BlockPool::Init ( int nBlockSize,
int nNumBlocks,
void * pMemory )

Take over a region as a chain of free blocks.

Parameters
nBlockSizeThe size of each block in bytes.
nNumBlocksThe number of blocks.
pMemoryThe region.
Ghidra address:
NTSC-U/C: 0x0029daa0
Ghidra address:
PAL: 0x002a7768

◆ Alloc()

void * BlockPool::Alloc ( )

Hand out the first free block.

Returns
The block, or null when none is free.
Ghidra address:
NTSC-U/C: 0x0029db18
Ghidra address:
PAL: 0x002a77e0

◆ Free()

void BlockPool::Free ( void * pBlock)

Return a block to the head of the chain.

Parameters
pBlockThe block.
Ghidra address:
NTSC-U/C: 0x0029db38
Ghidra address:
PAL: 0x002a7800

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