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

Function enrich_node_properties

src/mcp/mcp.c:4060–4094  ·  view source on GitHub ↗

Enrich a mutable JSON object with key-value pairs from a node's properties_json. * Returns the parsed yyjson_doc (caller frees AFTER serialization — zero-copy). */

Source from the content-addressed store, hash-verified

4058/* Enrich a mutable JSON object with key-value pairs from a node's properties_json.
4059 * Returns the parsed yyjson_doc (caller frees AFTER serialization — zero-copy). */
4060static yyjson_doc *enrich_node_properties(yyjson_mut_doc *doc, yyjson_mut_val *obj,
4061 const char *properties_json) {
4062 if (!properties_json || properties_json[0] == '\0') {
4063 return NULL;
4064 }
4065 yyjson_doc *props_doc = yyjson_read(properties_json, strlen(properties_json), 0);
4066 if (!props_doc) {
4067 return NULL;
4068 }
4069 yyjson_val *props_root = yyjson_doc_get_root(props_doc);
4070 if (!props_root || !yyjson_is_obj(props_root)) {
4071 yyjson_doc_free(props_doc);
4072 return NULL;
4073 }
4074 yyjson_obj_iter iter;
4075 yyjson_obj_iter_init(props_root, &iter);
4076 yyjson_val *key;
4077 while ((key = yyjson_obj_iter_next(&iter))) {
4078 yyjson_val *val = yyjson_obj_iter_get_val(key);
4079 const char *k = yyjson_get_str(key);
4080 if (!k) {
4081 continue;
4082 }
4083 if (yyjson_is_str(val)) {
4084 yyjson_mut_obj_add_str(doc, obj, k, yyjson_get_str(val));
4085 } else if (yyjson_is_bool(val)) {
4086 yyjson_mut_obj_add_bool(doc, obj, k, yyjson_get_bool(val));
4087 } else if (yyjson_is_int(val)) {
4088 yyjson_mut_obj_add_int(doc, obj, k, yyjson_get_int(val));
4089 } else if (yyjson_is_real(val)) {
4090 yyjson_mut_obj_add_real(doc, obj, k, yyjson_get_real(val));
4091 }
4092 }
4093 return props_doc; /* caller frees after serialization */
4094}
4095
4096/* Resolve an absolute path from root_path + file_path, verify containment,
4097 * and read source lines. Sets *out_abs_path (caller frees). Returns source

Callers 2

emit_search_resultsFunction · 0.85
build_snippet_responseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected