MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / fill_interior_page

Function fill_interior_page

internal/cbm/sqlite_writer.c:636–659  ·  view source on GitHub ↗

Fill an interior page with cells from children[*idx..child_count-2]. Updates cell_count, content_offset, ptr_offset, and *idx.

Source from the content-addressed store, hash-verified

634// Fill an interior page with cells from children[*idx..child_count-2].
635// Updates cell_count, content_offset, ptr_offset, and *idx.
636static void fill_interior_page(uint8_t *page, const PageRef *children, int child_count,
637 bool is_index, int *idx, int *cell_count, int *content_offset,
638 int *ptr_offset) {
639 while (*idx < child_count - SKIP_ONE) {
640 uint8_t tbuf[INTERIOR_CELL_BUF];
641 uint8_t *heap_cell = NULL;
642 int clen = build_interior_cell(&children[*idx], is_index, tbuf, &heap_cell);
643 uint8_t *cell_data = heap_cell ? heap_cell : tbuf;
644
645 int available = *content_offset - *ptr_offset - CELL_PTR_SIZE;
646 if (clen > available && *cell_count > 0) {
647 free(heap_cell);
648 break;
649 }
650
651 *content_offset -= clen;
652 memcpy(page + *content_offset, cell_data, clen);
653 put_u16(page + *ptr_offset, (uint16_t)*content_offset);
654 *ptr_offset += CELL_PTR_SIZE;
655 (*cell_count)++;
656 free(heap_cell);
657 (*idx)++;
658 }
659}
660
661static uint32_t pb_build_interior(PageBuilder *pb, bool is_index) {
662 if (!pb->leaves) {

Callers 1

pb_build_interiorFunction · 0.85

Calls 2

build_interior_cellFunction · 0.85
put_u16Function · 0.85

Tested by

no test coverage detected