| 345 | } |
| 346 | |
| 347 | static int json_escaped_len(const char *src) { |
| 348 | if (!src) { |
| 349 | return 0; |
| 350 | } |
| 351 | int len = 0; |
| 352 | for (int i = 0; src[i]; i++) { |
| 353 | unsigned char c = (unsigned char)src[i]; |
| 354 | if (c == '"' || c == '\\' || c == '\n' || c == '\r' || c == '\t') { |
| 355 | len += 2; |
| 356 | } else if (c < 0x20) { |
| 357 | len += 6; /* \u00XX */ |
| 358 | } else { |
| 359 | len++; |
| 360 | } |
| 361 | } |
| 362 | return len; |
| 363 | } |
| 364 | |
| 365 | static bool json_append_bool(char *buf, int buf_size, int *off, const char *name, bool value, |
| 366 | bool comma) { |
no outgoing calls
no test coverage detected