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

Function write_sqlite_file_header

internal/cbm/sqlite_writer.c:1891–1915  ·  view source on GitHub ↗

Write the SQLite file header on page 1 with master entries. */

Source from the content-addressed store, hash-verified

1889
1890/* Write the SQLite file header on page 1 with master entries. */
1891static void write_sqlite_file_header(uint8_t *page1, uint32_t total_pages) {
1892 memcpy(page1, "SQLite format 3\000", 16);
1893 put_u16(page1 + HDR_OFF_CBM_PAGE_SIZE,
1894 CBM_PAGE_SIZE == SQLITE_MAX_PAGE_SIZE ? (uint16_t)SKIP_ONE : (uint16_t)CBM_PAGE_SIZE);
1895 page1[HDR_OFF_WRITE_VERSION] = FILE_FORMAT;
1896 page1[HDR_OFF_READ_VERSION] = FILE_FORMAT;
1897 page1[HDR_OFF_RESERVED] = 0;
1898 page1[HDR_OFF_MAX_EMBED_FRAC] = MAX_EMBED_FRACTION;
1899 page1[HDR_OFF_MIN_EMBED_FRAC] = MIN_EMBED_FRACTION;
1900 page1[HDR_OFF_LEAF_FRAC] = LEAF_PAYLOAD_FRACTION;
1901 put_u32(page1 + HDR_OFF_FILE_CHANGE, SKIP_ONE);
1902 put_u32(page1 + HDR_OFF_DB_SIZE, total_pages);
1903 put_u32(page1 + HDR_OFF_FREELIST_TRUNK, 0);
1904 put_u32(page1 + HDR_OFF_FREELIST_COUNT, 0);
1905 put_u32(page1 + HDR_OFF_SCHEMA_COOKIE, SKIP_ONE);
1906 put_u32(page1 + HDR_OFF_SCHEMA_FORMAT, SCHEMA_FORMAT);
1907 put_u32(page1 + HDR_OFF_DEFAULT_CACHE, 0);
1908 put_u32(page1 + HDR_OFF_AUTOVAC_TOP, 0);
1909 put_u32(page1 + HDR_OFF_TEXT_ENCODING, SKIP_ONE);
1910 put_u32(page1 + HDR_OFF_USER_VERSION, 0);
1911 put_u32(page1 + HDR_OFF_INCR_VACUUM, 0);
1912 put_u32(page1 + HDR_OFF_APP_ID, 0);
1913 put_u32(page1 + HDR_OFF_VERSION_VALID, SKIP_ONE);
1914 put_u32(page1 + HDR_OFF_SQLITE_VERSION, SQLITE_VERSION);
1915}
1916
1917/* Build master records, write page 1 B-tree + file header. */
1918static int write_master_page1(FILE *fp, MasterEntry *master, int master_count, uint32_t next_page) {

Callers 1

write_master_page1Function · 0.85

Calls 2

put_u16Function · 0.85
put_u32Function · 0.85

Tested by

no test coverage detected