Match a single grep hit to the tightest containing node, then add to sr or raw. */
| 4893 | |
| 4894 | /* Match a single grep hit to the tightest containing node, then add to sr or raw. */ |
| 4895 | static 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. */ |
| 4913 | static void free_file_nodes(cbm_node_t *nodes, int count) { |
no test coverage detected