How to free json_object?

I have the following code

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>

#include <json/json.h>

int main(int argc, char **argv)
{
      json_object *new_obj;
      char buf[] = "{ \"foo\": \"bar\", \"foo2\": \"bar2\", \"foo3\": \"bar3\" }";
      new_obj = json_tokener_parse(buf);
      .....
      json_object_put(new_obj);
}

json_object_put(new_obj)is json_object_put(new_obj)all memory associated with new_obj?

+9
source share
2 answers

From the documentation:

void json_object_put    (struct json_object *this)  

Decrease json_object reference count and free it if it reaches zero

Source: http://oss.metaparadigm.com/json-c/doc/html/json__object_8h.html

+5
source

We do not need to free memory. The answer to this question can be found in this other question .

0
source

All Articles