| 101 | } |
| 102 | |
| 103 | static struct json *json_parse(const tal_t * ctx, const char *str) |
| 104 | { |
| 105 | struct json *j = tal(ctx, struct json); |
| 106 | j->buffer = tal_strdup(j, str); |
| 107 | convert_quotes(j->buffer); |
| 108 | |
| 109 | j->toks = tal_arr(j, jsmntok_t, 50); |
| 110 | assert(j->toks); |
| 111 | jsmn_parser parser; |
| 112 | |
| 113 | again: |
| 114 | jsmn_init(&parser); |
| 115 | int ret = jsmn_parse(&parser, j->buffer, strlen(j->buffer), j->toks, |
| 116 | tal_count(j->toks)); |
| 117 | if (ret == JSMN_ERROR_NOMEM) { |
| 118 | tal_resize(&j->toks, tal_count(j->toks) * 2); |
| 119 | goto again; |
| 120 | } |
| 121 | |
| 122 | if (ret <= 0) { |
| 123 | assert(0); |
| 124 | } |
| 125 | return j; |
| 126 | } |
| 127 | |
| 128 | static void zero_params(void) |
| 129 | { |
no test coverage detected