Function cJSON_Delete

Synopsis

#include <cJSON.h>

void cJSON_Delete(cJSON *item)

Description

Delete a cJSON entity and all subentities.

Delete a cJSON structure.

Mentioned in

Source

Lines 253-274 in cJSON.c. Line 165 in cJSON.h.

CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
{
    cJSON *next = NULL;
    while (item != NULL)
    {
        next = item->next;
        if (!(item->type & cJSON_IsReference) && (item->child != NULL))
        {
            cJSON_Delete(item->child);
        }
        if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL))
        {
            global_hooks.deallocate(item->valuestring);
        }
        if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
        {
            global_hooks.deallocate(item->string);
        }
        global_hooks.deallocate(item);
        item = next;
    }
}





Add Discussion as Guest

Log in