Append transitive_loop_depth + recursive to a node's properties JSON object. */
| 81 | |
| 82 | /* Append transitive_loop_depth + recursive to a node's properties JSON object. */ |
| 83 | static void append_complexity_props(cbm_gbuf_node_t *node, int tld, bool recursive) { |
| 84 | const char *old = node->properties_json ? node->properties_json : "{}"; |
| 85 | size_t olen = strlen(old); |
| 86 | if (olen < 2 || old[olen - 1] != '}') { |
| 87 | return; /* not a JSON object — leave untouched */ |
| 88 | } |
| 89 | bool empty = (olen == 2); /* "{}" */ |
| 90 | char *neu = cbm_alloc(CBM_MEM_CLASS_OTHER, olen + CBM_SZ_64); |
| 91 | if (!neu) { |
| 92 | return; |
| 93 | } |
| 94 | memcpy(neu, old, olen - 1); /* copy without trailing '}' */ |
| 95 | int w = |
| 96 | snprintf(neu + (olen - 1), CBM_SZ_64, "%s\"transitive_loop_depth\":%d,\"recursive\":%s}", |
| 97 | empty ? "" : ",", tld, recursive ? "true" : "false"); |
| 98 | if (w < 0) { |
| 99 | cbm_free(CBM_MEM_CLASS_OTHER, neu); |
| 100 | return; |
| 101 | } |
| 102 | (void)cbm_gbuf_node_set_properties_json(node, neu); |
| 103 | cbm_free(CBM_MEM_CLASS_OTHER, neu); |
| 104 | } |
| 105 | |
| 106 | /* Content-only node order: qualified_name, then file path and start line. |
| 107 | * Never the temp id: extract workers draw ids from one shared counter, so id |
no test coverage detected