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

Function dk_copy_json

src/pipeline/pass_docker.c:599–615  ·  view source on GitHub ↗

A COPY / ADD in JSON form: its strings, expanded. */

Source from the content-addressed store, hash-verified

597
598/* A COPY / ADD in JSON form: its strings, expanded. */
599static int dk_copy_json(dk_t *d, const char *p, const char **out, int max) {
600 yyjson_doc *doc = yyjson_read(p, strlen(p), YYJSON_READ_STOP_WHEN_DONE);
601 yyjson_val *arr = doc ? yyjson_doc_get_root(doc) : NULL;
602 int n = 0;
603 yyjson_arr_iter it;
604 yyjson_val *v;
605 if (yyjson_is_arr(arr)) {
606 for (yyjson_arr_iter_init(arr, &it); n < max && (v = yyjson_arr_iter_next(&it));) {
607 const char *s = yyjson_get_str(v);
608 out[n++] = s ? dk_expand(d, d->local, cbm_arena_strdup(d->a, s)) : NULL;
609 }
610 }
611 if (doc) {
612 yyjson_doc_free(doc);
613 }
614 return n;
615}
616
617/* COPY / ADD as Docker reads it, from the instruction's own text: flags
618 * first, then the JSON form or whitespace-separated words (a heredoc

Callers 1

dk_copyFunction · 0.85

Calls 2

dk_expandFunction · 0.85
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected