| 393 | } |
| 394 | |
| 395 | static int json_escaped_len(const char *src) { |
| 396 | if (!src) { |
| 397 | return 0; |
| 398 | } |
| 399 | int len = 0; |
| 400 | for (int i = 0; src[i]; i++) { |
| 401 | unsigned char c = (unsigned char)src[i]; |
| 402 | if (c == '"' || c == '\\' || c == '\n' || c == '\r' || c == '\t') { |
| 403 | len += 2; |
| 404 | } else if (c < 0x20) { |
| 405 | len += 6; /* \u00XX */ |
| 406 | } else { |
| 407 | len++; |
| 408 | } |
| 409 | } |
| 410 | return len; |
| 411 | } |
| 412 | |
| 413 | static bool json_append_bool(char *buf, int buf_size, int *off, const char *name, bool value, |
| 414 | bool comma) { |
no outgoing calls
no test coverage detected