Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of json_object_to_json_string gives no information about memory management #268

Closed
qnet-herwin opened this issue Sep 13, 2016 · 2 comments

Comments

@qnet-herwin
Copy link

https://json-c.github.io/json-c/json-c-0.12.1/doc/html/json__object_8h.html#a1f62a660e2619559d1f3f54cd7483ff8

The documentation here just tells us a string is returned, not how the memory management is done. By experimentation, I kind of figured out that there's no need to free the memory, which makes me suspect the memory is coupled to the obj parameter and freed as soon as the object is freed, but making this kind of things explicit would be welcome.

@hawicz
Copy link
Member

hawicz commented Sep 13, 2016

Yes, you're right, the lifetime of the returned string is limited to the lifetime of the json_object. Actually, it's probably also freed if any other call to _to_json_string is made.
I'll try to dig up the details later today, but feel free to submit a pull request if you have a reasonable (and accurate) description you want added to the doc.

@qnet-herwin
Copy link
Author

Tried to start with the documentation, then noticed that the master branch had them already (commit 37f5d86)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants