wavelength 1.0.0
Loading...
Searching...
No Matches
fixedsizealloc.h
Go to the documentation of this file.
1#pragma once
2
3#include "os/freestore.h"
4#include "os/prnstream.h"
5
13public:
15 static constexpr int kNumStores = 128;
16
24
34 void *Alloc(int nSize, int nUnused);
35
44 void Free(void *pBlock, int nSize);
45
53 void Report(PrnStream &stream);
54
63 static int StoreIndex(int nSize);
64
73 static int StoreNodeWords(int nIndex);
74
75private:
76 FreeStore *mStores[kNumStores];
77};
FixedSizeAlloc()
Construct an allocator with no stores yet.
void * Alloc(int nSize, int nUnused)
Hand out a block from the store of its size, creating the store on first use.
static int StoreNodeWords(int nIndex)
Report the node size of a store.
static int StoreIndex(int nSize)
Report the store a size of block takes.
void Free(void *pBlock, int nSize)
Return a block to the store of its size.
void Report(PrnStream &stream)
Write the use of each store and the bytes their free nodes take.
static constexpr int kNumStores
The node sizes, one for each 16 bytes.
Definition fixedsizealloc.h:15
Free list of nodes of one size, grown a chunk of nodes at a time from the hunks of the pool.
Definition freestore.h:14
Text output stream.
Definition prnstream.h:16