Closed rabhat31 closed 2 years ago
Of course not, you must not free it.
How/where does the memory pointed to by (buf) get deallocated in that case?
Say I use lyd_print_mem instead of lyd_print_clb, I get the resulting dump as a char **, which I can technically deallocate explicitly right?
How/where does the memory pointed to by (buf) get deallocated in that case?
Well, the printer API fully manages it, you should not worry about that.
Say I use lyd_print_mem instead of lyd_print_clb, I get the resulting dump as a char **, which I can technically deallocate explicitly right?
Yes, that is different API.
Well, the printer API fully manages it, you should not worry about that.
I'd like to understand at what point this happens please. We're debugging an issue on our system where our memory size is growing quite significantly. Using valgrind and Massif, we've got some clues about where this is memory is being allocated and it always points to ly_print() through lyd_print_clb(). If I had some more clarity about how the (buf) is being deallocated, it would be really helpful to understand how to further debug this issue.
Are there any limitations to buffer size returned by lyd_print_mem() ? The writeclb in lyd_print_clb() returns a void pointer and the size of the buffer. If we only wanted a character pointer at the end of it all, could we just use these two functions interchangeably?
I think this is the code block correct?
case LYOUT_CALLBACK: ... ... free(msg); break; }
.
Yes, that seems to be it, the buffer is allocated and then immediately freed so not sure what problems may that cause.
Hi, I have a question about the lyd_print_clb function from libyang1. https://netopeer.liberouter.org/doc/libyang/libyang1/html/group__datatree.html#ga6f340a456ffd6ed26263151c642d9f4a
Is it the duty of the caller to free the buffer (buf) in the callback function even though its declared a const void *?