wavelength 1.0.0
Loading...
Searching...
No Matches
MemMgr.h File Reference
#include "utl/Heap.h"
#include "utl/PrnStream.h"
Include dependency graph for MemMgr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int MemCurrentHeap ()
 Report the heap new allocations come from.
void MemFreeBlockStats (int heapNum, int *numBlocks, int *freeBytes, int *biggestBlock)
 Report the free runs of a heap.
void MemGetSystemMemory (int **begin, int **end)
 Take the memory the heaps are carved from from the C runtime.
int MemAddHeap (const char *name, int *start, int sizeWords, bool flag)
 Add a heap.
void MemResizeHeap (int heapNum, int sizeWords)
 Move the end of a heap.
void MemPushHeap (int iHeap)
 Make a heap the source of new allocations until MemPopHeap().
void MemPopHeap ()
 Return to the heap in use before the last MemPushHeap().
void MemPreInit ()
 Set up the main heap over all system memory.
void MemInit ()
 Split system memory into the heaps of the heaps_pc configuration and set up the pools.
void * MemAlloc (int size, const char *name, int align)
 Allocate from the current heap.
void MemFree (void *mem)
 Free an allocation of any heap.
int MemFindHeap (const char *name)
 Find a heap by name.
void MemPrintHeap (int heapNum, PrnStream &stream)
 Print every allocation of a heap.

Variables

const int MAX_HEAPS = 16
 Number of heaps the memory manager can hold.
Heap gHeaps [MAX_HEAPS]
 The heaps.
int gNumHeaps
 Number of heaps in use.
bool gMemTracking
 Whether allocations are reported to the memory tracker.
bool gTrackStl
 Whether STL allocations are named after their element type for the memory tracker.

Function Documentation

◆ MemCurrentHeap()

int MemCurrentHeap ( )

Report the heap new allocations come from.

Returns
The heap on top of the heap stack.
Ghidra address:
0x100100f0

◆ MemFreeBlockStats()

void MemFreeBlockStats ( int heapNum,
int * numBlocks,
int * freeBytes,
int * biggestBlock )

Report the free runs of a heap.

Parameters
heapNumThe heap.
numBlocksReceives the number of free runs.
freeBytesReceives the bytes in all free runs.
biggestBlockReceives the bytes in the largest free run.
Ghidra address:
0x10010100

◆ MemGetSystemMemory()

void MemGetSystemMemory ( int ** begin,
int ** end )

Take the memory the heaps are carved from from the C runtime.

Parameters
beginReceives the first word.
endReceives the word past the end.
Ghidra address:
0x10010150

◆ MemAddHeap()

int MemAddHeap ( const char * name,
int * start,
int sizeWords,
bool flag )

Add a heap.

Parameters
nameThe heap's name.
startThe first word of the heap.
sizeWordsThe size of the heap in words.
flagThe third value of the heap's configuration entry.
Returns
The new heap's index.
Ghidra address:
0x10010170

◆ MemResizeHeap()

void MemResizeHeap ( int heapNum,
int sizeWords )

Move the end of a heap.

Parameters
heapNumThe heap.
sizeWordsThe new size in words.
Ghidra address:
0x100101b0

◆ MemPushHeap()

void MemPushHeap ( int iHeap)

Make a heap the source of new allocations until MemPopHeap().

Parameters
iHeapThe heap.
Ghidra address:
0x10010770

◆ MemPopHeap()

void MemPopHeap ( )

Return to the heap in use before the last MemPushHeap().

Ghidra address:
0x100107e0

◆ MemPreInit()

void MemPreInit ( )

Set up the main heap over all system memory.

MemAlloc() calls the routine when no heap exists yet.

Ghidra address:
0x100107f0

◆ MemInit()

void MemInit ( )

Split system memory into the heaps of the heaps_pc configuration and set up the pools.

Only the first call has an effect.

Ghidra address:
0x10010870

◆ MemAlloc()

void * MemAlloc ( int size,
const char * name,
int align )

Allocate from the current heap.

Parameters
sizeThe size in bytes.
nameThe allocation's name for the memory tracker.
alignThe alignment in bytes, or zero for the default of 16.
Returns
The allocation.
Ghidra address:
0x10010a90

◆ MemFree()

void MemFree ( void * mem)

Free an allocation of any heap.

A pointer outside every heap fails.

Parameters
memThe allocation, or null.
Ghidra address:
0x10010b80

◆ MemFindHeap()

int MemFindHeap ( const char * name)

Find a heap by name.

Parameters
nameThe name.
Returns
The heap's index, or -1.
Ghidra address:
0x10010c40

◆ MemPrintHeap()

void MemPrintHeap ( int heapNum,
PrnStream & stream )

Print every allocation of a heap.

Parameters
heapNumThe heap.
streamThe destination.
Ghidra address:
0x10010ca0

Variable Documentation

◆ MAX_HEAPS

const int MAX_HEAPS = 16

Number of heaps the memory manager can hold.

◆ gHeaps

Heap gHeaps[MAX_HEAPS]
extern

The heaps.

Ghidra address:
0x100c1130

◆ gNumHeaps

int gNumHeaps
extern

Number of heaps in use.

Ghidra address:
0x100c13b8

◆ gMemTracking

bool gMemTracking
extern

Whether allocations are reported to the memory tracker.

Ghidra address:
0x100c13c5

◆ gTrackStl

bool gTrackStl
extern

Whether STL allocations are named after their element type for the memory tracker.

Ghidra address:
0x100c13c6