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

Function unit_add_using

src/pipeline/doc_links_cs.c:1522–1544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1520}
1521
1522static bool unit_add_using(cs_index_t *ix, cs_unit_t *u, char kind, const char *alias,
1523 const char *target) {
1524 if (u->nusings >= u->cap) {
1525 int ncap = u->cap ? u->cap * PAIR_LEN : CBM_SZ_8;
1526 cs_using_t *grown = (cs_using_t *)ix_alloc(ix, (size_t)ncap * sizeof(cs_using_t));
1527 if (!grown) {
1528 return false;
1529 }
1530 if (u->nusings > 0) {
1531 memcpy(grown, u->usings, (size_t)u->nusings * sizeof(cs_using_t));
1532 }
1533 u->usings = grown;
1534 u->cap = ncap;
1535 }
1536 char *a = ix_strdup(ix, alias);
1537 char *t = ix_strdup(ix, target);
1538 if (!a || !t) {
1539 return false;
1540 }
1541 u->usings[u->nusings++] = (cs_using_t){
1542 .kind = kind, .global = true, .alias = a, .target = t, .ns = CS_NONE, .ent = CS_NONE};
1543 return true;
1544}
1545
1546static int unit_using_cmp(const void *a, const void *b) {
1547 const cs_using_t *x = (const cs_using_t *)a;

Callers 1

units_collect_usingsFunction · 0.85

Calls 2

ix_allocFunction · 0.70
ix_strdupFunction · 0.70

Tested by

no test coverage detected