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

Function pb_ensure_leaf_cap

internal/cbm/sqlite_writer.c:1075–1091  ·  view source on GitHub ↗

Ensure leaves array has capacity for one more entry. Returns false on allocation failure.

Source from the content-addressed store, hash-verified

1073// Ensure leaves array has capacity for one more entry.
1074// Returns false on allocation failure.
1075static bool pb_ensure_leaf_cap(PageBuilder *pb) {
1076 if (pb->leaf_count < pb->leaf_cap) {
1077 return true;
1078 }
1079 pb->leaf_cap = pb->leaf_cap == 0 ? INITIAL_LEAF_CAP : pb->leaf_cap * GROWTH_FACTOR;
1080 void *tmp = realloc(pb->leaves, (size_t)pb->leaf_cap * sizeof(PageRef));
1081 if (!tmp) {
1082 /* Same consistent-empty contract as pb_flush_leaf's growth path. */
1083 free(pb->leaves);
1084 pb->leaves = NULL;
1085 pb->leaf_count = 0;
1086 pb->leaf_cap = 0;
1087 return false;
1088 }
1089 pb->leaves = (PageRef *)tmp;
1090 return true;
1091}
1092
1093// SQLite overflow thresholds for leaf table B-tree pages (PAGE_SIZE=65536, reserved=0):
1094// usable = PAGE_SIZE = 65536

Callers 4

pb_place_table_cellFunction · 0.85
pb_finalize_tableFunction · 0.85
pb_promote_and_flushFunction · 0.85
write_index_btreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected