Go to the source code of this file.
|
| int | ZoneCreate (const char *pszName, int nSize) |
| | Create a named zone.
|
| void * | ZoneAlloc (unsigned nSize) |
| | Allocate from the current zone.
|
| void * | ZoneGrabTemp (int nSize) |
| | Take the shared temporary buffer.
|
| void | ZoneInit (int nEnabled) |
| | Turn zone allocation on or off.
|
| void | FreeAllZones () |
| | Release every zone and clear the table.
|
| void | InitializeZoneList () |
| | Create every zone on the start-up list.
|
| void | ZoneDelete (int nZone) |
| | Release one zone and free its table slot.
|
| void | ReleaseAllZoneSlots () |
| | Release every zone one slot at a time.
|
| int | FindZoneByName (const char *pszName) |
| | Find a zone by name.
|
| void | ZoneSetCurrent (int nZone) |
| | Select the zone that ZoneAlloc() allocates from.
|
| int | ZoneGetCurrent () |
| | Report the selected zone.
|
| void | ZoneReset () |
| | Rewind the selected zone, discarding everything allocated from it.
|
| void | ZoneResetZone (int nZone) |
| | Rewind one zone, discarding everything allocated from it.
|
| void | ZoneFree (void *pBlock) |
| | Release a block that ZoneAlloc() returned.
|
| int | ZoneGetAvail (int nDefault) |
| | Report the space left in the selected zone.
|
| int | FindZoneForPointer (const void *pBlock) |
| | Find the zone a block belongs to.
|
| void | ZoneReleaseTemp () |
| | Give the shared temporary buffer back.
|
| void | ZoneDump () |
| | Write every occupied zone to the log.
|
|
| constexpr int | kZoneCount = 12 |
| | The number of zones the allocator can create at once.
|
| constexpr int | kZoneNameSize = 16 |
| | The number of bytes a zone name may occupy, including the terminator.
|
| constexpr int | kNoZone = -1 |
| | Reported in place of a zone index when no zone applies.
|
| Zone | zoneDescs [kZoneCount] |
| | The zone table.
|
| ZoneConfig | g_aZoneConfigs [] |
| | The start-up zone list, terminated by an entry with a null name.
|
◆ ZoneCreate()
| int ZoneCreate |
( |
const char * | pszName, |
|
|
int | nSize ) |
Create a named zone.
The region is over-allocated by 63 bytes so the usable start can be rounded up to a 64-byte boundary. A duplicate name, an exhausted table, and a failed allocation are all reported through the log and produce kNoZone.
- Parameters
-
| pszName | The zone name, which must fit in kZoneNameSize bytes with its terminator. |
| nSize | The usable size in bytes. |
- Returns
- The zone index, or kNoZone on failure and when zones are switched off.
- Ghidra address:
- NTSC-U/C: 0x00461190
- Ghidra address:
- PAL: 0x0049e850
◆ ZoneAlloc()
| void * ZoneAlloc |
( |
unsigned | nSize | ) |
|
Allocate from the current zone.
The request is rounded up to 16 bytes and taken by advancing the zone cursor. Exhausting the zone is fatal. With zones switched off, and while no zone is current, the request goes to MemAllocTagged() instead.
- Parameters
-
| nSize | The request in bytes. |
- Returns
- The block, or null when the current zone slot is empty.
- Ghidra address:
- NTSC-U/C: 0x004612e0
- Ghidra address:
- PAL: 0x0049e9a0
◆ ZoneGrabTemp()
| void * ZoneGrabTemp |
( |
int | nSize | ) |
|
Take the shared temporary buffer.
The buffer is the whole of the zone called temp, or a 128 KiB tagged allocation when zones are switched off. It is claimed once and stays claimed until ZoneReleaseTemp() runs, and a second claim is fatal.
- Parameters
-
| nSize | The size the caller needs in bytes, which the routine never reads. The buffer is not checked against it. |
- Returns
- The buffer.
- Ghidra address:
- NTSC-U/C: 0x004613d0
- Ghidra address:
- PAL: 0x0049ea90
◆ ZoneInit()
| void ZoneInit |
( |
int | nEnabled | ) |
|
Turn zone allocation on or off.
Switching the setting while zones are on releases every zone first.
- Parameters
-
| nEnabled | Non-zero to allow zones to be created. |
- Ghidra address:
- NTSC-U/C: 0x00461518
- Ghidra address:
- PAL: 0x0049ebd8
◆ FreeAllZones()
Release every zone and clear the table.
The whole table is zeroed in one pass, which is what distinguishes this routine from ReleaseAllZoneSlots(). The enabled flag is not consulted.
- Ghidra address:
- NTSC-U/C: 0x00461558
- Ghidra address:
- PAL: 0x0049ec18
◆ InitializeZoneList()
| void InitializeZoneList |
( |
| ) |
|
Create every zone on the start-up list.
- Ghidra address:
- NTSC-U/C: 0x004615d8
- Ghidra address:
- PAL: 0x0049ec98
◆ ZoneDelete()
| void ZoneDelete |
( |
int | nZone | ) |
|
Release one zone and free its table slot.
Deleting the current zone also clears the current-zone selection.
- Parameters
-
- Ghidra address:
- NTSC-U/C: 0x00461628
- Ghidra address:
- PAL: 0x0049ece8
◆ ReleaseAllZoneSlots()
| void ReleaseAllZoneSlots |
( |
| ) |
|
Release every zone one slot at a time.
Each occupied slot goes through the ZoneDelete() path, which respects the enabled flag and clears the current-zone selection.
- Ghidra address:
- NTSC-U/C: 0x004616c8
- Ghidra address:
- PAL: 0x0049ed88
◆ FindZoneByName()
| int FindZoneByName |
( |
const char * | pszName | ) |
|
Find a zone by name.
- Parameters
-
- Returns
- The zone index, or kNoZone when no zone has that name.
- Ghidra address:
- NTSC-U/C: 0x00461770
- Ghidra address:
- PAL: 0x0049ee30
◆ ZoneSetCurrent()
| void ZoneSetCurrent |
( |
int | nZone | ) |
|
Select the zone that ZoneAlloc() allocates from.
The index is stored without a range check. Passing kNoZone routes later requests to MemAllocTagged().
- Parameters
-
- Ghidra address:
- NTSC-U/C: 0x004617f8
- Ghidra address:
- PAL: 0x0049eeb8
◆ ZoneGetCurrent()
Report the selected zone.
- Returns
- The zone index, or kNoZone when no zone is selected.
- Ghidra address:
- NTSC-U/C: 0x00461818
- Ghidra address:
- PAL: 0x0049eed8
◆ ZoneReset()
Rewind the selected zone, discarding everything allocated from it.
- Ghidra address:
- NTSC-U/C: 0x00461828
- Ghidra address:
- PAL: 0x0049eee8
◆ ZoneResetZone()
| void ZoneResetZone |
( |
int | nZone | ) |
|
Rewind one zone, discarding everything allocated from it.
- Parameters
-
- Ghidra address:
- NTSC-U/C: 0x00461850
- Ghidra address:
- PAL: 0x0049ef10
◆ ZoneFree()
| void ZoneFree |
( |
void * | pBlock | ) |
|
Release a block that ZoneAlloc() returned.
A block cut out of a zone cannot be released on its own, so this does nothing while a zone is selected. The call is forwarded to MemFreeTagged() only on the paths where ZoneAlloc() would have used MemAllocTagged().
- Parameters
-
| pBlock | The block to release. |
- Ghidra address:
- NTSC-U/C: 0x004618b0
- Ghidra address:
- PAL: 0x0049ef70
◆ ZoneGetAvail()
| int ZoneGetAvail |
( |
int | nDefault | ) |
|
Report the space left in the selected zone.
- Parameters
-
| nDefault | The value to report when zones are switched off. |
- Returns
- The unused bytes of the selected zone, nDefault when zones are switched off, and zero when no zone is selected or the selected slot is empty.
- Ghidra address:
- NTSC-U/C: 0x00461900
- Ghidra address:
- PAL: 0x0049efc0
◆ FindZoneForPointer()
| int FindZoneForPointer |
( |
const void * | pBlock | ) |
|
Find the zone a block belongs to.
- Parameters
-
| pBlock | The block to locate. |
- Returns
- The zone index, or kNoZone when the block is in no zone.
- Ghidra address:
- NTSC-U/C: 0x00461968
- Ghidra address:
- PAL: 0x0049f028
◆ ZoneReleaseTemp()
Give the shared temporary buffer back.
The buffer itself is retained for the next claim. Only the claim is cleared.
- Ghidra address:
- NTSC-U/C: 0x004619c8
- Ghidra address:
- PAL: 0x0049f088
◆ ZoneDump()
Write every occupied zone to the log.
- Ghidra address:
- NTSC-U/C: 0x004619d8
- Ghidra address:
- PAL: 0x0049f098
◆ kZoneCount
The number of zones the allocator can create at once.
Every loop over the table is written against this count, and FreeAllZones() clears kZoneCount * sizeof(Zone) bytes in one call.
◆ kZoneNameSize
The number of bytes a zone name may occupy, including the terminator.
◆ kNoZone
Reported in place of a zone index when no zone applies.
◆ zoneDescs
The zone table.
- Ghidra address:
- NTSC-U/C: 0x008945a0
- Ghidra address:
- PAL: 0x008d8ca0
◆ g_aZoneConfigs
The start-up zone list, terminated by an entry with a null name.
- Ghidra address:
- NTSC-U/C: 0x006e9810
- Ghidra address:
- PAL: 0x0072d1a8