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

Function php_sb_put

internal/cbm/doclink_php.c:353–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351} php_sb_t;
352
353static void php_sb_put(php_sb_t *sb, const char *s, size_t n) {
354 if (sb->oom) {
355 return;
356 }
357 if (sb->len + n + SKIP_ONE > sb->cap) {
358 size_t ncap = sb->cap ? sb->cap * PAIR_LEN : CBM_SZ_256;
359 while (ncap < sb->len + n + SKIP_ONE) {
360 ncap *= PAIR_LEN;
361 }
362 char *grown = (char *)cbm_arena_alloc(sb->a, ncap);
363 if (!grown) {
364 sb->oom = true;
365 return;
366 }
367 if (sb->len) {
368 memcpy(grown, sb->buf, sb->len);
369 }
370 sb->buf = grown;
371 sb->cap = ncap;
372 }
373 memcpy(sb->buf + sb->len, s, n);
374 sb->len += n;
375 sb->buf[sb->len] = '\0';
376}
377
378static void php_sb_puts(php_sb_t *sb, const char *s) {
379 php_sb_put(sb, s, strlen(s));

Callers 2

php_sb_putsFunction · 0.85
php_sb_fieldFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected