| 3344 | } compare_response_t; |
| 3345 | |
| 3346 | static char *compare_graphs_error(const char *code, const char *message) { |
| 3347 | yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); |
| 3348 | yyjson_mut_val *root = doc ? yyjson_mut_obj(doc) : NULL; |
| 3349 | if (!doc || !root) { |
| 3350 | yyjson_mut_doc_free(doc); |
| 3351 | return cbm_mcp_text_result("compare_graphs failed: out of memory", true); |
| 3352 | } |
| 3353 | yyjson_mut_doc_set_root(doc, root); |
| 3354 | if (!yyjson_mut_obj_add_strcpy(doc, root, "error", message) || |
| 3355 | !yyjson_mut_obj_add_strcpy(doc, root, "code", code)) { |
| 3356 | yyjson_mut_doc_free(doc); |
| 3357 | return cbm_mcp_text_result("compare_graphs failed: out of memory", true); |
| 3358 | } |
| 3359 | char *json = yy_doc_to_str(doc); |
| 3360 | yyjson_mut_doc_free(doc); |
| 3361 | if (!json) { |
| 3362 | return cbm_mcp_text_result("compare_graphs failed: out of memory", true); |
| 3363 | } |
| 3364 | char *result = cbm_mcp_text_result(json, true); |
| 3365 | free(json); |
| 3366 | return result; |
| 3367 | } |
| 3368 | |
| 3369 | static bool compare_arg_name_allowed(const char *name) { |
| 3370 | return strcmp(name, "base_project") == 0 || strcmp(name, "target_project") == 0 || |
no test coverage detected