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

Function search_code_context_object

tests/test_mcp.c:23986–24005  ·  view source on GitHub ↗

Row-0 context object of a json-format search_code answer, or NULL when the * answer carries no context column. *doc_out owns the memory either way. */

Source from the content-addressed store, hash-verified

23984/* Row-0 context object of a json-format search_code answer, or NULL when the
23985 * answer carries no context column. *doc_out owns the memory either way. */
23986static yyjson_val *search_code_context_object(const char *inner, yyjson_doc **doc_out) {
23987 *doc_out = yyjson_read(inner, strlen(inner), 0);
23988 if (!*doc_out) {
23989 return NULL;
23990 }
23991 yyjson_val *root = yyjson_doc_get_root(*doc_out);
23992 yyjson_val *cols = yyjson_obj_get(root, "cols");
23993 yyjson_val *rows = yyjson_obj_get(root, "rows");
23994 if (!cols || !rows || yyjson_arr_size(rows) == 0) {
23995 return NULL;
23996 }
23997 size_t col_count = yyjson_arr_size(cols);
23998 for (size_t i = 0; i < col_count; i++) {
23999 const char *col = yyjson_get_str(yyjson_arr_get(cols, i));
24000 if (col && strcmp(col, "context") == 0) {
24001 return yyjson_arr_get(yyjson_arr_get(rows, 0), i);
24002 }
24003 }
24004 return NULL;
24005}
24006
24007static int count_newlines(const char *s) {
24008 int n = 0;

Callers 1

test_mcp.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected