resonance 1.0.1
Loading...
Searching...
No Matches
zone.h
Go to the documentation of this file.
1#pragma once
2
9constexpr int kZoneCount = 12;
10
12constexpr int kZoneNameSize = 16;
13
15constexpr int kNoZone = -1;
16
28struct Zone {
29 void *mBlock;
30 char *mStart;
31 char *mCur;
32 int mSize;
34};
35
60struct ZoneConfig {
61 const char *mName;
62 int mSizeKb;
63};
64
80int ZoneCreate(const char *pszName, int nSize);
81
94void *ZoneAlloc(unsigned nSize);
95
109void *ZoneGrabTemp(int nSize);
110
120void ZoneInit(int nEnabled);
121
132
140
150void ZoneDelete(int nZone);
151
162
171int FindZoneByName(const char *pszName);
172
183void ZoneSetCurrent(int nZone);
184
193
201
209void ZoneResetZone(int nZone);
210
222void ZoneFree(void *pBlock);
223
234int ZoneGetAvail(int nDefault);
235
244int FindZoneForPointer(const void *pBlock);
245
255
262void ZoneDump();
263
271
One entry of the start-up zone list.
Definition zone.h:60
int mSizeKb
Definition zone.h:62
const char * mName
Definition zone.h:61
One named region the allocator hands blocks out of.
Definition zone.h:28
char * mCur
Definition zone.h:31
void * mBlock
Definition zone.h:29
int mSize
Definition zone.h:32
char * mStart
Definition zone.h:30
char mName[kZoneNameSize]
Definition zone.h:33
int ZoneGetAvail(int nDefault)
Report the space left in the selected zone.
void ZoneSetCurrent(int nZone)
Select the zone that ZoneAlloc() allocates from.
constexpr int kZoneNameSize
The number of bytes a zone name may occupy, including the terminator.
Definition zone.h:12
void ZoneDelete(int nZone)
Release one zone and free its table slot.
void InitializeZoneList()
Create every zone on the start-up list.
void FreeAllZones()
Release every zone and clear the table.
void ZoneResetZone(int nZone)
Rewind one zone, discarding everything allocated from it.
void ZoneReset()
Rewind the selected zone, discarding everything allocated from it.
ZoneConfig g_aZoneConfigs[]
The start-up zone list, terminated by an entry with a null name.
void * ZoneGrabTemp(int nSize)
Take the shared temporary buffer.
int ZoneCreate(const char *pszName, int nSize)
Create a named zone.
void * ZoneAlloc(unsigned nSize)
Allocate from the current zone.
constexpr int kZoneCount
The number of zones the allocator can create at once.
Definition zone.h:9
constexpr int kNoZone
Reported in place of a zone index when no zone applies.
Definition zone.h:15
void ReleaseAllZoneSlots()
Release every zone one slot at a time.
int FindZoneByName(const char *pszName)
Find a zone by name.
void ZoneDump()
Write every occupied zone to the log.
void ZoneReleaseTemp()
Give the shared temporary buffer back.
int FindZoneForPointer(const void *pBlock)
Find the zone a block belongs to.
void ZoneInit(int nEnabled)
Turn zone allocation on or off.
void ZoneFree(void *pBlock)
Release a block that ZoneAlloc() returned.
Zone zoneDescs[kZoneCount]
The zone table.
int ZoneGetCurrent()
Report the selected zone.