Count SIMILAR_TO edges in graph buffer. */
| 43 | |
| 44 | /* Count SIMILAR_TO edges in graph buffer. */ |
| 45 | static int count_similar_to_edges(const cbm_gbuf_t *gb) { |
| 46 | int count = 0; |
| 47 | /* Iterate all edges via label-based node search + edge queries */ |
| 48 | const cbm_gbuf_node_t **funcs = NULL; |
| 49 | int func_count = 0; |
| 50 | cbm_gbuf_find_by_label(gb, "Function", &funcs, &func_count); |
| 51 | for (int i = 0; i < func_count; i++) { |
| 52 | const cbm_gbuf_edge_t **edges = NULL; |
| 53 | int edge_count = 0; |
| 54 | cbm_gbuf_find_edges_by_source_type(gb, funcs[i]->id, "SIMILAR_TO", &edges, &edge_count); |
| 55 | count += edge_count; |
| 56 | } |
| 57 | const cbm_gbuf_node_t **methods = NULL; |
| 58 | int method_count = 0; |
| 59 | cbm_gbuf_find_by_label(gb, "Method", &methods, &method_count); |
| 60 | for (int i = 0; i < method_count; i++) { |
| 61 | const cbm_gbuf_edge_t **edges = NULL; |
| 62 | int edge_count = 0; |
| 63 | cbm_gbuf_find_edges_by_source_type(gb, methods[i]->id, "SIMILAR_TO", &edges, &edge_count); |
| 64 | count += edge_count; |
| 65 | } |
| 66 | return count; |
| 67 | } |
| 68 | |
| 69 | /* Large Go function template for fingerprint tests. Must have enough |
| 70 | * structural diversity (>= 32 unique structural trigrams) after leaf-only |
no test coverage detected