-
Notifications
You must be signed in to change notification settings - Fork 261
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
memory issue for recursive function #151
Comments
@Edwardmark I don't have much experience with cpp, but you are passing the same |
@nixzhu Thanks for you reply. I want to convert a tree structure to json, so I have to use the same doc pointer. The problem is about the jsonNode or SubNode in the recursion function. I print the value, it shows when the bottom recursion end, the upper function call cannot get their value, print result is null. |
It is not about cpp, I want to verify if the doc owns its subnode memory when calling the recursion function? And what should I do to fix the issue? Thanks . |
@Edwardmark The doc holds memory for all json values, so the recursive call seems good. There are two string handling issues:
If you share the |
@ibireme Thanks for your reply. It is the problem. I change yyjson_mut_str() to yyjson_mut_strcpy() and it worked. |
Just call |
@ibireme Thanks. |
I have a TreeNode class which defines a tree structure. And I want to convert it to json using yyjson.
The expected output should be:
But the actual result in main is NULL, and the cout << json_str << endl; in the recursion function outputs:
It seems that the result is destructed when the function call end, so it returns null.
So what is the problem? Why the result is null? Could you please give me some hits? Thanks. @TkTech @lundmark @ibireme @nixzhu @fd00 Thanks.
The text was updated successfully, but these errors were encountered: