Skip to main content

Module allocator

Module allocator 

Source
Expand description

Page allocator for save_database (SQLR-6).

Replaces the bare next_free_page: u32 counter that the staging code used to thread through every stage_*_btree function. The allocator draws from three pools, in order of preference:

  1. Per-table preferred pool — pages the table previously occupied, seeded by [set_preferred]. An unchanged table’s stage produces byte-identical pages at the same numbers, so the diff pager skips every write for it.
  2. Global freelist — pages dropped tables/indexes used to occupy plus the trunk pages of the previously-persisted freelist.
  3. Extendnext_extend++, monotonic past the current high water.

After staging finishes, [high_water] is the new page_count and [used] enumerates every page actually written this save (so the caller can compute the new freelist as old_live − used).

Structs§

PageAllocator
Hands out page numbers during a save.