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

Function write_empty_index_leaf

internal/cbm/sqlite_writer.c:1319–1332  ·  view source on GitHub ↗

Write an empty index leaf page.

Source from the content-addressed store, hash-verified

1317
1318// Write an empty index leaf page.
1319static uint32_t write_empty_index_leaf(FILE *fp, uint32_t *next_page) {
1320 *next_page = cbm_skip_pending_byte(*next_page);
1321 uint32_t pnum = (*next_page)++;
1322 uint8_t page[CBM_PAGE_SIZE];
1323 memset(page, 0, CBM_PAGE_SIZE);
1324 page[0] = NEWLINE_BYTE;
1325 put_u16(page + HDR_FREEBLOCK_OFF, 0);
1326 put_u16(page + HDR_CELLCOUNT_OFF, 0);
1327 put_u16(page + HDR_CONTENT_OFF, (uint16_t)CBM_PAGE_SIZE);
1328 page[HDR_FRAGBYTES_OFF] = 0;
1329 (void)fseek(fp, (long)(pnum - SKIP_ONE) * CBM_PAGE_SIZE, SEEK_SET);
1330 (void)fwrite(page, SKIP_ONE, CBM_PAGE_SIZE, fp);
1331 return pnum;
1332}
1333
1334// Write leaf pages for an index, returns root page.
1335static uint32_t write_index_btree(FILE *fp, uint32_t *next_page, uint8_t **cells, int *cell_lens,

Callers 1

write_index_btreeFunction · 0.85

Calls 3

cbm_skip_pending_byteFunction · 0.85
put_u16Function · 0.85
fwriteFunction · 0.85

Tested by

no test coverage detected