File: zzjson_free.c

package info (click to toggle)
syslinux 3%3A6.03%2Bdfsg-14.1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 41,508 kB
  • sloc: ansic: 358,767; asm: 9,608; pascal: 4,809; perl: 3,894; makefile: 2,486; sh: 315; python: 266; xml: 39
file content (29 lines) | stat: -rw-r--r-- 829 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* JSON free
 * ZZJSON - Copyright (C) 2008 by Ivo van Poorten
 * License: GNU Lesser General Public License version 2.1
 */

#include "zzjson.h"

void zzjson_free(ZZJSON_CONFIG *config, ZZJSON *zzjson) {
    while (zzjson) {
        ZZJSON *next;
        switch(zzjson->type) {
            case ZZJSON_OBJECT:
                config->free(zzjson->value.object.label);
                zzjson_free(config, zzjson->value.object.val);
                break;
            case ZZJSON_ARRAY:
                zzjson_free(config, zzjson->value.array.val);
                break;
            case ZZJSON_STRING:
                config->free(zzjson->value.string.string);
                break;
            default:
                break;
        }
        next = zzjson->next;
        config->free(zzjson);
        zzjson = next;
    }
}