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

Function classify_grep_hit

src/mcp/mcp.c:4895–4910  ·  view source on GitHub ↗

Match a single grep hit to the tightest containing node, then add to sr or raw. */

Source from the content-addressed store, hash-verified

4893
4894/* Match a single grep hit to the tightest containing node, then add to sr or raw. */
4895static void classify_grep_hit(grep_match_t *hit, cbm_node_t *file_nodes, int file_node_count,
4896 search_result_t **sr, int *sr_count, int *sr_cap, grep_match_t **raw,
4897 int *raw_count, int *raw_cap) {
4898 int best = find_tightest_node(file_nodes, file_node_count, hit->line);
4899 if (best >= 0) {
4900 add_to_search_results(sr, sr_count, sr_cap, &file_nodes[best], hit->line);
4901 } else {
4902 if (*raw_count >= *raw_cap) {
4903 *raw_cap = (*raw_cap == 0) ? CBM_SZ_32 : *raw_cap * PAIR_LEN;
4904 *raw = safe_realloc(*raw, *raw_cap * sizeof(grep_match_t));
4905 }
4906 if (*raw) {
4907 (*raw)[(*raw_count)++] = *hit;
4908 }
4909 }
4910}
4911
4912/* Free a file_nodes array returned from cbm_store_find_nodes_by_file. */
4913static void free_file_nodes(cbm_node_t *nodes, int count) {

Callers 1

classify_all_grep_hitsFunction · 0.85

Calls 3

find_tightest_nodeFunction · 0.85
add_to_search_resultsFunction · 0.85
safe_reallocFunction · 0.85

Tested by

no test coverage detected