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

Function dk_json_string

src/pipeline/pass_docker.c:535–552  ·  view source on GitHub ↗

JSON string `s` (quoted) unquoted; \\ and \" unescaped. */

Source from the content-addressed store, hash-verified

533
534/* JSON string `s` (quoted) unquoted; \\ and \" unescaped. */
535static const char *dk_json_string(dk_t *d, const char *s) {
536 size_t l = s ? strlen(s) : 0;
537 if (l < PAIR_LEN || s[0] != '"') {
538 return s;
539 }
540 char *out = cbm_arena_alloc(d->a, l);
541 size_t n = 0;
542 for (size_t i = SKIP_ONE; out && i + SKIP_ONE < l; i++) {
543 if (s[i] == '\\' && i + PAIR_LEN < l) {
544 i++;
545 }
546 out[n++] = s[i];
547 }
548 if (out) {
549 out[n] = '\0';
550 }
551 return out;
552}
553
554/* The strings of a json_string_array node. */
555static int dk_json_array(dk_t *d, TSNode arr, const char **out, int max) {

Callers 1

dk_json_arrayFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.50

Tested by

no test coverage detected