Skip to main content

Module freelist

Module freelist 

Source
Expand description

Freelist representation.

Format version 0 uses an in-page linked list: the file header’s freelist_head points at the most-recently-freed page, and each freelist page stores the PageId of the next one (or 0 for the end of the list). See docs/format.md § Freelist representation.

At M2 the freelist holds at most one id per page (the head of the list). M3 extends the freelist page to also store a bulk array of freed ids; that extension is forward-compatible (Rule 5 — the on- disk type tag does not change).

This module exposes pure encode / decode helpers. The pager (super::Pager) is responsible for sequencing the writes; keeping the codec separate makes it easy to unit-test in isolation and to re-use from the verifier/CLI in later milestones.

Structs§

FreeListPage
In-memory view of a freelist page.

Constants§

TYPE_FREE_LIST
On-disk type tag for a freelist page. See docs/format.md.

Functions§

decode
Decode a freelist page. Caller is responsible for checking the page trailer (issue #6).
encode
Encode entry into page. The page-trailer region (last PAGE_TRAILER_SIZE bytes) is left zero; the pager writes the trailer (issue #6).