wavelength 1.0.0
Loading...
Searching...
No Matches
Heap.h
Go to the documentation of this file.
1#pragma once
2
3#include "utl/FreeBlock.h"
4#include "utl/PrnStream.h"
5
12 unsigned int mSizeWords : 24;
13 unsigned int mPadWords : 8;
14};
15
22class Heap {
23public:
36 void Init(const char *name, int num, int *start, int sizeWords, bool flag);
37
46 void FreeBlockStats(int *numBlocks, int *freeBytes, int *biggestBlock);
47
54 void Resize(int sizeWords);
55
68 void *Alloc(int sizeWords, const char *name, int alignBits, int *allocatedWords);
69
77 bool Free(void *mem);
78
87 void Print(PrnStream &stream, bool summary);
88
94 int *Start() const {
95 return mStart;
96 }
97
103 int SizeWords() const {
104 return mSizeWords;
105 }
106
112 const char *Name() const {
113 return mName;
114 }
115
116private:
126 void
127 InsertFreeBlock(FreeBlock *iBlock, int sizeWords, FreeBlock *iPrevBlock, FreeBlock *iNextBlock);
128
137 void FindNeighbors(int *addr, FreeBlock **prev, FreeBlock **next);
138
139 FreeBlock *mFreeList;
140 int *mStart;
141 const char *mName;
142 int mSizeWords;
143 int mNum;
144 bool mFlag; // +0x14, stored by Init() and not read by any routine.
145};
Free block of a Heap, a node of the heap's free list in address order.
Definition heap.h:10
Region of memory that hands out word-aligned blocks from a free list, best fit first.
Definition heap.h:38
void FindNeighbors(void *pAddress, FreeBlock **ppPrev, FreeBlock **ppNext)
Find the free blocks on each side of an address.
bool Free(void *mem)
Return an allocation to the free list, merging it with its neighbours.
void Init(const char *name, int num, int *start, int sizeWords, bool flag)
Take over a region of memory as one free run.
void Resize(int sizeWords)
Grow or shrink the heap by moving its end.
void InsertFreeBlock(FreeBlock *pBlock, int nSizeWords, FreeBlock *pPrev, FreeBlock *pNext)
Make a free block of a region and link it between two free blocks.
const char * Name() const
Report the heap's name.
Definition Heap.h:112
int SizeWords() const
Report the size of the heap.
Definition Heap.h:103
int * Start() const
Report the first word of the heap.
Definition Heap.h:94
void * Alloc(int sizeWords, const char *name, int alignBits, int *allocatedWords)
Allocate from the smallest free run that fits.
void FreeBlockStats(int *numBlocks, int *freeBytes, int *biggestBlock)
Report the free runs.
void Print(PrnStream &stream, bool summary)
Print every run of the heap.
Text output stream.
Definition prnstream.h:16
int start(int argc, char **argv)
The Conexant USB modem driver registers with usbd and drives each matching modem for the modem librar...
Word in front of every allocation a heap hands out.
Definition Heap.h:11
unsigned int mPadWords
Definition Heap.h:13
unsigned int mSizeWords
Definition Heap.h:12