akheron / jansson

C library for encoding, decoding and manipulating JSON data
http://www.digip.org/jansson/
Other
3.05k stars 811 forks source link

Does replacing a key decrements the reference count ? #529

Closed Sunslash closed 4 years ago

Sunslash commented 4 years ago

Hello, I am currently writing an application using jansson, and I would like to avoid any memory issues.

Let's say I have added a key to a json object json_object_set_new(my_json, "key", my_value);

And then later decide to replace the value json_object_set(my_json, "key", my_new_value);

What happens to the old json object ? Is it decremented and destroyed ? Or should I manage this myself ?

Mephistophiles commented 4 years ago

Yep, it will be decremented and destroyed. Stacktrace:

Sunslash commented 4 years ago

Perfect, thanks