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

Function py_put

internal/cbm/doclink_py.c:52–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50} py_sb_t;
51
52static void py_put(py_sb_t *sb, const char *s, size_t n) {
53 if (sb->failed) {
54 return;
55 }
56 if (sb->len + n + 1 > sb->cap) {
57 size_t ncap = sb->cap ? sb->cap : PY_SB_INIT;
58 while (ncap < sb->len + n + 1) {
59 ncap *= 2;
60 }
61 char *grown = (char *)cbm_arena_alloc(sb->a, ncap);
62 if (!grown) {
63 sb->failed = true;
64 return;
65 }
66 if (sb->len > 0) {
67 memcpy(grown, sb->buf, sb->len);
68 }
69 sb->buf = grown;
70 sb->cap = ncap;
71 }
72 memcpy(sb->buf + sb->len, s, n);
73 sb->len += n;
74 sb->buf[sb->len] = '\0';
75}
76
77/* One record: its kind, then each field after a TAB, then a newline. */
78static void py_rec(py_sb_t *sb, const char *kind, int nfields, const char *const *f,

Callers 2

py_recFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected