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

Function extract_prop_string

src/graph_buffer/graph_buffer.c:1375–1391  ·  view source on GitHub ↗

Extract a string property from a properties JSON string. * Returns heap-allocated string or NULL. Caller must free. * Parses real JSON: the dump writer feeds these values into indexes whose * backing columns are GENERATED AS json_extract(properties,'$. '). * Naive byte slicing returned the ESCAPED text (and cut at embedded \\") * while json_extract yields the unescaped value — the mismatc

Source from the content-addressed store, hash-verified

1373 * "missing from index idx_edges_url_path" under PRAGMA integrity_check.
1374 * key_quoted ("\"key\"") is a fast pre-filter to skip the JSON parse. */
1375static char *extract_prop_string(const char *props, const char *key_quoted, const char *key) {
1376 if (!props || !strstr(props, key_quoted)) {
1377 return NULL;
1378 }
1379 yyjson_doc *doc = yyjson_read(props, strlen(props), 0);
1380 if (!doc) {
1381 return NULL;
1382 }
1383 char *out = NULL;
1384 yyjson_val *v = yyjson_obj_get(yyjson_doc_get_root(doc), key);
1385 if (v && yyjson_is_str(v)) {
1386 const char *sv = yyjson_get_str(v);
1387 out = cbm_strndup(sv, strlen(sv));
1388 }
1389 yyjson_doc_free(doc);
1390 return out;
1391}
1392
1393static char *extract_url_path(const char *props) {
1394 return extract_prop_string(props, "\"url_path\"", "url_path");

Callers 2

extract_url_pathFunction · 0.85
extract_local_nameFunction · 0.85

Calls 1

cbm_strndupFunction · 0.85

Tested by

no test coverage detected