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

Function json_tok_remove

common/json_parse_simple.c:573–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573void json_tok_remove(jsmntok_t **tokens,
574 jsmntok_t *obj_or_array, const jsmntok_t *tok, size_t num)
575{
576 const jsmntok_t *src = tok;
577 const jsmntok_t *end = json_next(*tokens);
578 jsmntok_t *dest = *tokens + (tok - *tokens);
579 int remove_count;
580
581 assert(*tokens);
582 assert(obj_or_array->type == JSMN_ARRAY
583 || obj_or_array->type == JSMN_OBJECT);
584 /* obj_or_array must be inside tokens, and tok must be inside
585 * obj_or_array */
586 assert(obj_or_array >= *tokens
587 && obj_or_array < *tokens + tal_count(*tokens));
588 assert(tok >= obj_or_array
589 && tok < *tokens + tal_count(*tokens));
590
591 for (int i = 0; i < num; i++)
592 src = json_next(src);
593
594 /* Don't give us a num which goes over end of obj_or_array. */
595 assert(src <= json_next(obj_or_array));
596
597 remove_count = src - tok;
598
599 memmove(dest, src, sizeof(jsmntok_t) * (end - src));
600
601 /* Subtract first: this ptr may move after tal_resize! */
602 obj_or_array->size -= num;
603 tal_resize(tokens, tal_count(*tokens) - remove_count);
604}

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