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

Function sb_append

src/cli/client_adapter.c:26–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24} adapter_sb_t;
25
26static void sb_append(adapter_sb_t *sb, const char *s) {
27 if (sb->failed || !s) {
28 return;
29 }
30 size_t add = strlen(s);
31 if (sb->len + add + 1 > sb->cap) {
32 size_t want = sb->cap ? sb->cap : CBM_SZ_2K;
33 while (want < sb->len + add + 1) {
34 if (want > SIZE_MAX / PAIR_LEN) {
35 sb->failed = true;
36 return;
37 }
38 want *= PAIR_LEN;
39 }
40 char *grown = realloc(sb->buf, want);
41 if (!grown) {
42 sb->failed = true;
43 return;
44 }
45 sb->buf = grown;
46 sb->cap = want;
47 }
48 memcpy(sb->buf + sb->len, s, add);
49 sb->len += add;
50 sb->buf[sb->len] = '\0';
51}
52
53/* Append a single-quoted JavaScript string literal, escaping the characters
54 * that could terminate or corrupt it. Avoids the fixed buffer sizing that

Callers 6

sb_append_js_stringFunction · 0.85
emit_headerFunction · 0.85
append_typebox_typeFunction · 0.85
cbm_client_adapter_piFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected