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

Function dynbuf_ensure

internal/cbm/sqlite_writer.c:312–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312static bool dynbuf_ensure(DynBuf *b, int needed) {
313 if (b->len + needed <= b->cap) {
314 return true;
315 }
316 int newcap = b->cap == 0 ? INITIAL_PAGE_CAP : b->cap;
317 while (newcap < b->len + needed) {
318 newcap *= GROWTH_FACTOR;
319 }
320 uint8_t *p = (uint8_t *)realloc(b->data, newcap);
321 if (!p) {
322 (void)fprintf(stderr, "cbm_write_db: dynbuf realloc failed size=%d\n", newcap);
323 return false;
324 }
325 b->data = p;
326 b->cap = newcap;
327 return true;
328}
329
330static bool dynbuf_append(DynBuf *b, const void *data, int len) {
331 if (len <= 0) {

Callers 1

dynbuf_appendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected