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

Function build_dedup_files_array

src/mcp/mcp.c:4558–4590  ·  view source on GitHub ↗

Build deduplicated file list from search results + raw matches. */

Source from the content-addressed store, hash-verified

4556
4557/* Build deduplicated file list from search results + raw matches. */
4558static yyjson_mut_val *build_dedup_files_array(yyjson_mut_doc *doc, search_result_t *sr,
4559 int output_count, grep_match_t *raw, int raw_count) {
4560 yyjson_mut_val *files_arr = yyjson_mut_arr(doc);
4561 char *seen_files[CBM_SZ_512];
4562 int seen_count = 0;
4563 for (int fi = 0; fi < output_count; fi++) {
4564 bool dup = false;
4565 for (int j = 0; j < seen_count; j++) {
4566 if (strcmp(seen_files[j], sr[fi].file) == 0) {
4567 dup = true;
4568 break;
4569 }
4570 }
4571 if (!dup && seen_count < CBM_SZ_512) {
4572 seen_files[seen_count++] = sr[fi].file;
4573 yyjson_mut_arr_add_str(doc, files_arr, sr[fi].file);
4574 }
4575 }
4576 for (int fi = 0; fi < raw_count && seen_count < CBM_SZ_512; fi++) {
4577 bool dup = false;
4578 for (int j = 0; j < seen_count; j++) {
4579 if (strcmp(seen_files[j], raw[fi].file) == 0) {
4580 dup = true;
4581 break;
4582 }
4583 }
4584 if (!dup) {
4585 seen_files[seen_count++] = raw[fi].file;
4586 yyjson_mut_arr_add_str(doc, files_arr, raw[fi].file);
4587 }
4588 }
4589 return files_arr;
4590}
4591
4592/* Attach source or context lines to a search result JSON item. */
4593static void attach_result_source(yyjson_mut_doc *doc, yyjson_mut_val *item, search_result_t *r,

Callers 1

assemble_search_outputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected