Append transitive_loop_depth + recursive to a node's properties JSON object. */
| 77 | |
| 78 | /* Append transitive_loop_depth + recursive to a node's properties JSON object. */ |
| 79 | static void append_complexity_props(cbm_gbuf_node_t *node, int tld, bool recursive) { |
| 80 | const char *old = node->properties_json ? node->properties_json : "{}"; |
| 81 | size_t olen = strlen(old); |
| 82 | if (olen < 2 || old[olen - 1] != '}') { |
| 83 | return; /* not a JSON object — leave untouched */ |
| 84 | } |
| 85 | bool empty = (olen == 2); /* "{}" */ |
| 86 | char *neu = malloc(olen + CBM_SZ_64); |
| 87 | if (!neu) { |
| 88 | return; |
| 89 | } |
| 90 | memcpy(neu, old, olen - 1); /* copy without trailing '}' */ |
| 91 | int w = |
| 92 | snprintf(neu + (olen - 1), CBM_SZ_64, "%s\"transitive_loop_depth\":%d,\"recursive\":%s}", |
| 93 | empty ? "" : ",", tld, recursive ? "true" : "false"); |
| 94 | if (w < 0) { |
| 95 | free(neu); |
| 96 | return; |
| 97 | } |
| 98 | free(node->properties_json); |
| 99 | node->properties_json = neu; |
| 100 | } |
| 101 | |
| 102 | /* Memoized DFS: tld(id) = loop_depth(id) + max over CALLS-callees of tld(callee). |
| 103 | * state: 0=unvisited, 1=in-progress (back-edge → cycle), 2=done. */ |
no outgoing calls
no test coverage detected