Runs the traversal from every seed in canonical order; *tld_out[id] and * g->recursive[id] then hold each seed's result. */
| 283 | /* Runs the traversal from every seed in canonical order; *tld_out[id] and |
| 284 | * g->recursive[id] then hold each seed's result. */ |
| 285 | static bool tld_run(tld_graph_t *g, int **tld_out) { |
| 286 | size_t sz = (size_t)g->maxid + 1; |
| 287 | tld_ctx_t cx = {.g = g, .callee_cap = g->edge_count}; |
| 288 | cx.tld = cbm_calloc(CBM_MEM_CLASS_OTHER, sz * sizeof(*cx.tld)); |
| 289 | cx.state = cbm_calloc(CBM_MEM_CLASS_OTHER, sz * sizeof(*cx.state)); |
| 290 | cx.callees = cbm_calloc(CBM_MEM_CLASS_OTHER, ((size_t)g->edge_count + 1) * sizeof(*cx.callees)); |
| 291 | if (!cx.tld || !cx.state || !cx.callees) { |
| 292 | cbm_free(CBM_MEM_CLASS_OTHER, cx.tld); |
| 293 | cbm_free(CBM_MEM_CLASS_OTHER, cx.state); |
| 294 | cbm_free(CBM_MEM_CLASS_OTHER, cx.callees); |
| 295 | return false; |
| 296 | } |
| 297 | qsort(g->seeds, (size_t)g->seed_count, sizeof(*g->seeds), cmp_callee_canonical); |
| 298 | for (int i = 0; i < g->seed_count; i++) { |
| 299 | if (cx.state[g->seeds[i].id] != 2) { |
| 300 | tld_dfs(&cx, g->seeds[i].id, 0); |
| 301 | } |
| 302 | } |
| 303 | cbm_free(CBM_MEM_CLASS_OTHER, cx.state); |
| 304 | cbm_free(CBM_MEM_CLASS_OTHER, cx.callees); |
| 305 | *tld_out = cx.tld; |
| 306 | return true; |
| 307 | } |
| 308 | |
| 309 | static int label_count(const cbm_gbuf_t *gb, const char *label) { |
| 310 | const cbm_gbuf_node_t **nodes = NULL; |
no test coverage detected