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

Function json_tok_remove

common/json_parse_simple.c:530–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

528}
529
530void json_tok_remove(jsmntok_t **tokens,
531 jsmntok_t *obj_or_array, const jsmntok_t *tok, size_t num)
532{
533 const jsmntok_t *src = tok;
534 const jsmntok_t *end = json_next(*tokens);
535 jsmntok_t *dest = *tokens + (tok - *tokens);
536 int remove_count;
537
538 assert(*tokens);
539 assert(obj_or_array->type == JSMN_ARRAY
540 || obj_or_array->type == JSMN_OBJECT);
541 /* obj_or_array must be inside tokens, and tok must be inside
542 * obj_or_array */
543 assert(obj_or_array >= *tokens
544 && obj_or_array < *tokens + tal_count(*tokens));
545 assert(tok >= obj_or_array
546 && tok < *tokens + tal_count(*tokens));
547
548 for (int i = 0; i < num; i++)
549 src = json_next(src);
550
551 /* Don't give us a num which goes over end of obj_or_array. */
552 assert(src <= json_next(obj_or_array));
553
554 remove_count = src - tok;
555
556 memmove(dest, src, sizeof(jsmntok_t) * (end - src));
557
558 /* Subtract first: this ptr may move after tal_resize! */
559 obj_or_array->size -= num;
560 tal_resize(tokens, tal_count(*tokens) - remove_count);
561}

Callers 11

json_plugin_controlFunction · 0.85
json_checkFunction · 0.85
delete_format_hintFunction · 0.85
sanityFunction · 0.85
remove_oneFunction · 0.85
remove_firstFunction · 0.85
remove_lastFunction · 0.85
remove_multipleFunction · 0.85
remove_allFunction · 0.85
remove_complexFunction · 0.85
remove_inside_objFunction · 0.85

Calls 1

json_nextFunction · 0.70

Tested by 8

sanityFunction · 0.68
remove_oneFunction · 0.68
remove_firstFunction · 0.68
remove_lastFunction · 0.68
remove_multipleFunction · 0.68
remove_allFunction · 0.68
remove_complexFunction · 0.68
remove_inside_objFunction · 0.68