| 355 | } |
| 356 | |
| 357 | static int json_escaped_len(const char *src) { |
| 358 | if (!src) { |
| 359 | return 0; |
| 360 | } |
| 361 | int len = 0; |
| 362 | for (int i = 0; src[i]; i++) { |
| 363 | unsigned char c = (unsigned char)src[i]; |
| 364 | if (c == '"' || c == '\\' || c == '\n' || c == '\r' || c == '\t') { |
| 365 | len += 2; |
| 366 | } else if (c < 0x20) { |
| 367 | len += 6; /* \u00XX */ |
| 368 | } else { |
| 369 | len++; |
| 370 | } |
| 371 | } |
| 372 | return len; |
| 373 | } |
| 374 | |
| 375 | static bool json_append_bool(char *buf, int buf_size, int *off, const char *name, bool value, |
| 376 | bool comma) { |
no outgoing calls
no test coverage detected