| 20 | }; |
| 21 | |
| 22 | struct jsonrpc_io *jsonrpc_io_new(const tal_t *ctx) |
| 23 | { |
| 24 | struct jsonrpc_io *json_in; |
| 25 | const size_t bufsize = READ_CHUNKSIZE * 2; |
| 26 | |
| 27 | json_in = tal(ctx, struct jsonrpc_io); |
| 28 | json_in->bytes_read = 0; |
| 29 | |
| 30 | membuf_init(&json_in->membuf, |
| 31 | tal_arr(json_in, char, bufsize), |
| 32 | bufsize, membuf_tal_resize); |
| 33 | json_in->toks = toks_alloc(json_in); |
| 34 | jsmn_init(&json_in->parser); |
| 35 | |
| 36 | return json_in; |
| 37 | } |
| 38 | |
| 39 | /* Empty new bytes read into our unparsed buffer */ |
| 40 | static void add_newly_read(struct jsonrpc_io *json_in) |