Append an already-serialized JSON value verbatim: ,"key": . Atomic like * append_json_string. For `variants`, which extraction builds as a JSON array * of objects (cbm.h). Twin of pass_definitions.c -- keep both in sync. */
| 485 | * append_json_string. For `variants`, which extraction builds as a JSON array |
| 486 | * of objects (cbm.h). Twin of pass_definitions.c -- keep both in sync. */ |
| 487 | static void append_json_raw(char *buf, size_t bufsize, size_t *pos, const char *key, |
| 488 | const char *json) { |
| 489 | if (!json || json[0] == '\0') { |
| 490 | return; |
| 491 | } |
| 492 | size_t required = strlen(key) + strlen(json) + PP_JSON_FIELD_OVERHEAD; |
| 493 | if (*pos + required + PP_ESC_SPACE > bufsize) { |
| 494 | return; /* whole field would not fit — skip it atomically */ |
| 495 | } |
| 496 | int w = snprintf(buf + *pos, bufsize - *pos, ",\"%s\":%s", key, json); |
| 497 | if (w > 0 && (size_t)w < bufsize - *pos) { |
| 498 | *pos += (size_t)w; |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | static void build_def_props(char *buf, size_t bufsize, const CBMDefinition *def) { |
| 503 | /* Complexity/loop/recursion metrics are meaningful only for Function/Method. |