MiniDoom

src/z_zone.ml

Implements zone-style memory tagging and allocation lifecycle helpers.

Package
(global)
Reachable
Yes

Imports

Declarations

_Z_Align4

inline function _Z_Align4(n)

Rounds an allocation size upward to the allocator's four-byte boundary.

ParameterTypeDefaultDescription
ndynamic—Number of values to process.

View source

_Z_AssignUser

inline function _Z_AssignUser(user, ptr)

Writes an allocated payload offset through Doom's single-element owner-reference convention.

ParameterTypeDefaultDescription
userdynamic—User value supplied to `_Z_AssignUser`.
ptrdynamic—Ptr value supplied to `_Z_AssignUser`.

View source

_Z_blocklist

_Z_blocklist

Tracks the mutable z blocklist value used by the z zone subsystem.

View source

_Z_blocks

_Z_blocks

Holds the optional z blocks resource used by the z zone subsystem.

View source

_Z_buf

_Z_buf

Holds the optional z buf resource used by the z zone subsystem.

View source

_Z_FindBlockByPtr

inline function _Z_FindBlockByPtr(ptr)

Finds the allocated block whose payload begins at a zone-buffer offset, returning the sentinel index when absent.

ParameterTypeDefaultDescription
ptrdynamic—Ptr value supplied to `_Z_FindBlockByPtr`.

View source

_Z_Get

inline function _Z_Get(i)

Lazily initializes the zone and safely resolves an internal block-table index.

ParameterTypeDefaultDescription
idynamic—Zero-based iteration index.

View source

_Z_HDR

const _Z_HDR = 0

Defines z hdr for the z zone subsystem.

View source

_Z_IsFree

inline function _Z_IsFree(i)

Treats a block as free exactly when it has no owner marker.

ParameterTypeDefaultDescription
idynamic—Zero-based iteration index.

View source

_Z_LinkAfter

inline function _Z_LinkAfter(aIdx, bIdx)

Inserts one block after another and updates all four neighboring list links atomically.

ParameterTypeDefaultDescription
aIdxdynamic—A idx value supplied to `_Z_LinkAfter`.
bIdxdynamic—B idx value supplied to `_Z_LinkAfter`.

View source

_Z_NewBlock

inline function _Z_NewBlock(start, size, user, tag, id, next, prev)

Constructs a block descriptor without linking it into the zone list.

ParameterTypeDefaultDescription
startdynamic—Start value supplied to `_Z_NewBlock`.
sizedynamic—Requested size in bytes or elements.
userdynamic—User value supplied to `_Z_NewBlock`.
tagdynamic—Zone-memory or resource-lifetime tag.
iddynamic—Id value supplied to `_Z_NewBlock`.
nextdynamic—Next value supplied to `_Z_NewBlock`.
prevdynamic—Prev value supplied to `_Z_NewBlock`.

View source

_Z_NULL_OWNER_PTR

const _Z_NULL_OWNER_PTR = -1

Defines z null owner ptr for the z zone subsystem.

View source

_Z_rover

_Z_rover

Tracks the mutable z rover value used by the z zone subsystem.

View source

_Z_Set

inline function _Z_Set(i, b)

Updates a zone allocation block in the zone memory table.

ParameterTypeDefaultDescription
idynamic—Zero-based iteration index.
bdynamic—Second input operand.

View source

_Z_size

_Z_size

Tracks the mutable z size value used by the z zone subsystem.

View source

memblock_t struct

MINFRAGMENT

const MINFRAGMENT = 64

Defines the minimum minfragment accepted by the z zone subsystem.

View source

PU_CACHE

const PU_CACHE = 101

Defines pu cache for the z zone subsystem.

View source

PU_DAVE

const PU_DAVE = 4

Defines pu dave for the z zone subsystem.

View source

PU_LEVEL

const PU_LEVEL = 50

Defines pu level for the z zone subsystem.

View source

PU_LEVSPEC

const PU_LEVSPEC = 51

Defines pu levspec for the z zone subsystem.

View source

PU_MUSIC

const PU_MUSIC = 3

Defines pu music for the z zone subsystem.

View source

PU_PURGELEVEL

const PU_PURGELEVEL = 100

Defines pu purgelevel for the z zone subsystem.

View source

PU_SOUND

const PU_SOUND = 2

Defines pu sound for the z zone subsystem.

View source

PU_STATIC

const PU_STATIC = 1

Defines pu static for the z zone subsystem.

View source

Z_BytesAt

function Z_BytesAt(ptr, length)

Returns a byte slice copied from an absolute zone-buffer range.

ParameterTypeDefaultDescription
ptrdynamic—Ptr value supplied to `Z_BytesAt`.
lengthdynamic—Number of bytes or elements in the associated value.

View source

Z_ChangeTag

function Z_ChangeTag(ptr, tag)

Exposes the validated retagging operation under the original zone API name.

ParameterTypeDefaultDescription
ptrdynamic—Ptr value supplied to `Z_ChangeTag`.
tagdynamic—Zone-memory or resource-lifetime tag.

View source

Z_ChangeTag2

function Z_ChangeTag2(ptr, tag)

Retags a validated allocation while forbidding purgeable tags on blocks without an owner reference.

ParameterTypeDefaultDescription
ptrdynamic—Ptr value supplied to `Z_ChangeTag2`.
tagdynamic—Zone-memory or resource-lifetime tag.

View source

Z_CheckHeap

function Z_CheckHeap()

Verifies bidirectional links, contiguous address coverage, absence of adjacent free blocks, and the final zone extent.

View source

Z_ClearZone

function Z_ClearZone(zone)

Replaces all allocator metadata with a sentinel and one free block covering the complete zone buffer.

ParameterTypeDefaultDescription
zonedynamic—Zone value supplied to `Z_ClearZone`.

View source

Z_DumpHeap

function Z_DumpHeap(lowtag, hightag)

Prints allocator size and metadata for blocks in a selected tag range for diagnostics.

ParameterTypeDefaultDescription
lowtagdynamic—Lowtag value supplied to `Z_DumpHeap`.
hightagdynamic—Hightag value supplied to `Z_DumpHeap`.

View source

Z_FileDumpHeap

function Z_FileDumpHeap(f)

Preserves the legacy file-dump entry point by emitting the complete heap through the active diagnostic output.

ParameterTypeDefaultDescription
fdynamic—F value supplied to `Z_FileDumpHeap`.

View source

Z_Free

function Z_Free(ptr)

Validates and releases an allocation, invalidates its owner reference, and coalesces adjacent free blocks while repairing the rover.

ParameterTypeDefaultDescription
ptrdynamic—Ptr value supplied to `Z_Free`.

View source

Z_FreeMemory

function Z_FreeMemory()

Totals immediately free and purgeable bytes to estimate memory available for a future allocation.

View source

Z_FreeTags

function Z_FreeTags(lowtag, hightag)

Frees every allocated block whose purge tag lies in the inclusive requested range while preserving traversal across coalescing.

ParameterTypeDefaultDescription
lowtagdynamic—Lowtag value supplied to `Z_FreeTags`.
hightagdynamic—Hightag value supplied to `Z_FreeTags`.

View source

Z_GetZoneBuffer

function Z_GetZoneBuffer()

Returns the backing byte buffer addressed by all zone payload offsets.

View source

Z_Init

function Z_Init()

Obtains the platform zone buffer and initializes allocator metadata over its reported capacity.

View source

Z_Malloc

function Z_Malloc(size, tag, user)

Performs rover-based first-fit allocation, purges eligible tagged blocks, splits large remainders, and enforces owners for purgeable memory.

ParameterTypeDefaultDescription
sizedynamic—Requested size in bytes or elements.
tagdynamic—Zone-memory or resource-lifetime tag.
userdynamic—User value supplied to `Z_Malloc`.

View source

Z_PeekByte

function Z_PeekByte(ptr)

Reads one byte at an absolute zone-buffer offset.

ParameterTypeDefaultDescription
ptrdynamic—Ptr value supplied to `Z_PeekByte`.

View source

Z_PokeByte

function Z_PokeByte(ptr, v)

Writes the low eight bits of a value at an absolute zone-buffer offset.

ParameterTypeDefaultDescription
ptrdynamic—Ptr value supplied to `Z_PokeByte`.
vdynamic—Value consumed by the operation.

View source

Z_PokeBytes

function Z_PokeBytes(dstPtr, srcBytes, srcOff, length)

Copies a validated source byte range into the zone buffer at an absolute payload offset.

ParameterTypeDefaultDescription
dstPtrdynamic—Dst ptr value supplied to `Z_PokeBytes`.
srcBytesdynamic—Src bytes value supplied to `Z_PokeBytes`.
srcOffdynamic—Src off value supplied to `Z_PokeBytes`.
lengthdynamic—Number of bytes or elements in the associated value.

View source

ZONEID

const ZONEID = 1919505

Defines zoneid for the z zone subsystem.

View source