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:1035–1048  ·  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

1033// Ensure leaves array has capacity for one more entry.
1034// Returns false on allocation failure.
1035static bool pb_ensure_leaf_cap(PageBuilder *pb) {
1036 if (pb->leaf_count < pb->leaf_cap) {
1037 return true;
1038 }
1039 pb->leaf_cap = pb->leaf_cap == 0 ? INITIAL_LEAF_CAP : pb->leaf_cap * GROWTH_FACTOR;
1040 void *tmp = realloc(pb->leaves, (size_t)pb->leaf_cap * sizeof(PageRef));
1041 if (!tmp) {
1042 free(pb->leaves);
1043 pb->leaves = NULL;
1044 return false;
1045 }
1046 pb->leaves = (PageRef *)tmp;
1047 return true;
1048}
1049
1050// SQLite overflow thresholds for leaf table B-tree pages (PAGE_SIZE=65536, reserved=0):
1051// usable = PAGE_SIZE = 65536

Callers 4

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