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

Function sh_str_add

src/pipeline/pass_shell.c:547–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545} sh_str_t;
546
547static void sh_str_add(CBMArena *a, sh_str_t *b, const char *p, size_t n) {
548 if (b->bad || !p) {
549 b->bad = true;
550 return;
551 }
552 if (b->len + n + SKIP_ONE > b->cap) {
553 size_t ncap = (b->cap ? b->cap : SH_GROW_MIN) * PAIR_LEN;
554 while (ncap < b->len + n + SKIP_ONE) {
555 ncap *= PAIR_LEN;
556 }
557 char *nb = cbm_arena_alloc(a, ncap);
558 if (!nb) {
559 b->bad = true;
560 return;
561 }
562 if (b->len) {
563 memcpy(nb, b->buf, b->len);
564 }
565 b->buf = nb;
566 b->cap = ncap;
567 }
568 memcpy(b->buf + b->len, p, n);
569 b->len += n;
570 b->buf[b->len] = '\0';
571}
572
573static const char *sh_str_done(sh_str_t *b) {
574 if (b->bad) {

Callers 5

sh_add_unescapedFunction · 0.85
sh_concatFunction · 0.85
sh_url_templateFunction · 0.85
sh_httpFunction · 0.85
mk_expandFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.50

Tested by

no test coverage detected