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

Function json_tok_remove

common/json_parse_simple.c:623–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621}
622
623void json_tok_remove(jsmntok_t **tokens,
624 jsmntok_t *obj_or_array, const jsmntok_t *tok, size_t num)
625{
626 const jsmntok_t *src = tok;
627 const jsmntok_t *end = json_next(*tokens);
628 jsmntok_t *dest = *tokens + (tok - *tokens);
629 int remove_count;
630
631 assert(*tokens);
632 assert(obj_or_array->type == JSMN_ARRAY
633 || obj_or_array->type == JSMN_OBJECT);
634 /* obj_or_array must be inside tokens, and tok must be inside
635 * obj_or_array */
636 assert(obj_or_array >= *tokens
637 && obj_or_array < *tokens + tal_count(*tokens));
638 assert(tok >= obj_or_array
639 && tok < *tokens + tal_count(*tokens));
640
641 for (int i = 0; i < num; i++)
642 src = json_next(src);
643
644 /* Don't give us a num which goes over end of obj_or_array. */
645 assert(src <= json_next(obj_or_array));
646
647 remove_count = src - tok;
648
649 memmove(dest, src, sizeof(jsmntok_t) * (end - src));
650
651 /* Subtract first: this ptr may move after tal_resize! */
652 obj_or_array->size -= num;
653 tal_resize(tokens, tal_count(*tokens) - remove_count);
654}

Callers 12

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
ld_command_handleFunction · 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