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

Function cbm_doclinks_push

internal/cbm/doclink.c:399–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397enum { DOCLINK_INIT_CAP = 16 };
398
399void cbm_doclinks_push(CBMDocLinkArray *arr, CBMArena *a, CBMDocLink link) {
400 if (arr->count >= arr->cap) {
401 int ncap = arr->cap ? arr->cap * PAIR_LEN : DOCLINK_INIT_CAP;
402 CBMDocLink *grown;
403#if defined(CBM_ENABLE_TEST_SEAMS) && CBM_ENABLE_TEST_SEAMS
404 if (cbm_doclink_test_fail_alloc(CBM_DOCLINK_ALLOC_TOKENS)) {
405 grown = NULL;
406 } else
407#endif
408 {
409 grown = (CBMDocLink *)cbm_arena_alloc(a, (size_t)ncap * sizeof(*grown));
410 }
411 if (!grown) {
412 arr->failed = true; /* the token is lost: the layer must not say ok */
413 return;
414 }
415 if (arr->count > 0) {
416 memcpy(grown, arr->items, (size_t)arr->count * sizeof(*grown));
417 }
418 arr->items = grown;
419 arr->cap = ncap;
420 }
421 arr->items[arr->count++] = link;
422}
423
424typedef struct {
425 uint32_t line;

Callers 15

oa_operationFunction · 0.85
jv_pushFunction · 0.85
rs_push_tokenFunction · 0.85
md_emitFunction · 0.85
dg_linkFunction · 0.85
php_pushFunction · 0.85
emitFunction · 0.85
ad_pushFunction · 0.85
go_emitFunction · 0.85
ts_pushFunction · 0.85

Calls 2

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected