MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_cstr_from_hex

Function json_cstr_from_hex

plugins/bkpr/descriptions.c:191–204  ·  view source on GitHub ↗

To avoid JSON encoding/decoding, we use hex encoding directly */

Source from the content-addressed store, hash-verified

189
190/* To avoid JSON encoding/decoding, we use hex encoding directly */
191static char *json_cstr_from_hex(const tal_t *ctx, const char *buffer, const jsmntok_t *tok)
192{
193 char *result;
194 size_t hexlen, rawlen;
195 hexlen = tok->end - tok->start;
196 rawlen = hex_data_size(hexlen);
197
198 result = tal_arr(ctx, char, rawlen + 1);
199 if (!hex_decode(buffer + tok->start, hexlen, result, rawlen))
200 return tal_free(result);
201
202 result[rawlen] = '\0';
203 return result;
204}
205
206struct descriptions *init_descriptions(const tal_t *ctx,
207 struct command *init_cmd)

Callers 1

init_descriptionsFunction · 0.85

Calls 3

hex_data_sizeFunction · 0.85
hex_decodeFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected