Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
MemoryPoolSingleBlock Class Reference

Public Member Functions

void removeBlockFromList (MemoryPoolSingleBlock **pHead)
 
void initBlock (Int logicalSize, MemoryPoolBlob *owningBlob, MemoryPoolFactory *owningFactory DECLARE_LITERALSTRING_ARG2)
 
void * getUserData ()
 
MemoryPoolBlobgetOwningBlob ()
 
MemoryPoolSingleBlockgetNextFreeBlock ()
 
void setNextFreeBlock (MemoryPoolSingleBlock *b)
 
MemoryPoolSingleBlockgetNextRawBlock ()
 
void setNextRawBlock (MemoryPoolSingleBlock *b)
 

Static Public Member Functions

static Int calcRawBlockSize (Int logicalSize)
 
static MemoryPoolSingleBlockrawAllocateSingleBlock (MemoryPoolSingleBlock **pRawListHead, Int logicalSize, MemoryPoolFactory *owningFactory DECLARE_LITERALSTRING_ARG2)
 
static MemoryPoolSingleBlockrecoverBlockFromUserData (void *pUserData)
 

Detailed Description

This is the fundamental allocation unit; when you allocate via (say) MemoryPool::allocateBlock, this is what is being allocated for you. (Of course, you don't see the private fields.) For the most part, we allocate big chunks of these in a monolithic Blob and subdivide from there. (However, we occasionally allocate these individually, for large blocks.)

Note also that we directly allocate/free these with sysAllocate/sysFree, so ctors/dtors are never executed, nor would virtual functions work – I know, it's a little evil.

Definition at line 401 of file GameMemory.cpp.

Member Function Documentation

◆ calcRawBlockSize()

Int MemoryPoolSingleBlock::calcRawBlockSize ( Int logicalSize)
inlinestatic

given a desired logical block size, calculate the physical size needed for each MemoryPoolSingleBlock (including overhead, etc.)

Definition at line 563 of file GameMemory.cpp.

◆ getNextFreeBlock()

MemoryPoolSingleBlock * MemoryPoolSingleBlock::getNextFreeBlock ( )
inline

return the next free block in this blob. this call assumes that the block in question belongs to a blob, and will assert if not.

Definition at line 584 of file GameMemory.cpp.

◆ getNextRawBlock()

MemoryPoolSingleBlock * MemoryPoolSingleBlock::getNextRawBlock ( )
inline

return the next raw block in this dma. this call assumes that the block in question does NOT belong to a blob, and will assert if not.

Definition at line 612 of file GameMemory.cpp.

◆ getOwningBlob()

MemoryPoolBlob * MemoryPoolSingleBlock::getOwningBlob ( )
inline

accessor

Definition at line 575 of file GameMemory.cpp.

◆ getUserData()

void * MemoryPoolSingleBlock::getUserData ( )
inline

return a ptr to the user-data area of the block (ie, the part the enduser can deal with). this call verifies that the block is valid in debug mode.

Definition at line 550 of file GameMemory.cpp.

◆ initBlock()

void MemoryPoolSingleBlock::initBlock ( Int logicalSize,
MemoryPoolBlob * owningBlob,
MemoryPoolFactory *owningFactory DECLARE_LITERALSTRING_ARG2 )

fill in a block's fields. this is usually done only just after a block is allocated, but might also be done at other points in debug mode.

Definition at line 852 of file GameMemory.cpp.

◆ rawAllocateSingleBlock()

MemoryPoolSingleBlock * MemoryPoolSingleBlock::rawAllocateSingleBlock ( MemoryPoolSingleBlock ** pRawListHead,
Int logicalSize,
MemoryPoolFactory *owningFactory DECLARE_LITERALSTRING_ARG2 )
static

allocate and initialize a single block. this should only used by DynamicMemoryAllocator when allocating an extraordinarily large block.

Definition at line 928 of file GameMemory.cpp.

◆ recoverBlockFromUserData()

MemoryPoolSingleBlock * MemoryPoolSingleBlock::recoverBlockFromUserData ( void * pUserData)
static

given a 'public' ptr to a block (ie, the ptr returned by the MemoryPool::allocateBlock), recover the ptr to the MemoryPoolSingleBlock, so we can access the hidden fields.

Definition at line 906 of file GameMemory.cpp.

◆ removeBlockFromList()

void MemoryPoolSingleBlock::removeBlockFromList ( MemoryPoolSingleBlock ** pHead)

remove the block from the list, which is presumed to be a list of raw blocks. generally, only the DynamicMemoryAllocator should call this.

Definition at line 946 of file GameMemory.cpp.

◆ setNextFreeBlock()

void MemoryPoolSingleBlock::setNextFreeBlock ( MemoryPoolSingleBlock * b)
inline

set the next free block in this blob. this call assumes that both blocks in question belongs to a blob, but will NOT assert if not, since it may be called when the blocks are in an inconsistent state.

Definition at line 595 of file GameMemory.cpp.

◆ setNextRawBlock()

void MemoryPoolSingleBlock::setNextRawBlock ( MemoryPoolSingleBlock * b)
inline

set the next raw block in this dma. this call assumes that the blocks in question do NOT belong to a blob, and will assert if not.

Definition at line 622 of file GameMemory.cpp.


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