MCPcopy Create free account
hub / github.com/MariaDB/server / json_norm_value_free

Function json_norm_value_free

strings/json_normalize.c:437–535  ·  view source on GitHub ↗

Free the entire JSON tree iteratively. */

Source from the content-addressed store, hash-verified

435 Free the entire JSON tree iteratively.
436*/
437static void json_norm_value_free(struct json_norm_value *root)
438{
439 DYNAMIC_ARRAY stack;
440 struct json_norm_frame frame;
441 struct json_norm_value *val;
442 size_t i;
443
444 if (json_norm_init_dynamic_array(sizeof(struct json_norm_frame), &stack))
445 return;
446
447 frame.val= root;
448 frame.index= 0;
449 frame.visited= UNPROCESSED;
450 push_dynamic(&stack, &frame);
451
452 do
453 {
454 frame= *(struct json_norm_frame *)pop_dynamic(&stack);
455 val= frame.val;
456
457 if (!val)
458 continue;
459
460 if (frame.visited > UNPROCESSED)
461 {
462 switch (val->type)
463 {
464 case JSON_VALUE_OBJECT:
465 delete_dynamic(&val->value.object.kv_pairs);
466 break;
467
468 case JSON_VALUE_ARRAY:
469 delete_dynamic(&val->value.array.values);
470 break;
471
472 case JSON_VALUE_STRING:
473 json_norm_string_free(&val->value.string);
474 break;
475
476 case JSON_VALUE_NUMBER:
477 json_norm_number_free(&val->value.number);
478 break;
479
480 default: break;
481 }
482 val->type= JSON_VALUE_UNINITIALIZED;
483 continue;
484 }
485
486 frame.visited= CLOSE_NON_SCALAR;
487 push_dynamic(&stack, &frame);
488
489 switch (val->type)
490 {
491 case JSON_VALUE_OBJECT:
492 {
493 DYNAMIC_ARRAY *pairs= &val->value.object.kv_pairs;
494 for (i= 0; i < pairs->elements; i++)

Callers 3

json_normalizeFunction · 0.85

Calls 5

pop_dynamicFunction · 0.85
delete_dynamicFunction · 0.85
json_norm_string_freeFunction · 0.85
json_norm_number_freeFunction · 0.85

Tested by

no test coverage detected