I used the valgrind to fix the memory leak errors in the code. Hope this can help the future readers understand the book.
I also did the following:
Use the explicit initialization char *s = calloc(1024 * sizeof(char),1024); to ensure s not having weird characters which will influence strcat(s, indent);.
remove if (j > 0) to give one whole Btree graph.
add free_node function to ensure no crash due to the memory leak with many iterations.
I used the
valgrind
to fix the memory leak errors in the code. Hope this can help the future readers understand the book. I also did the following:char *s = calloc(1024 * sizeof(char),1024);
to ensures
not having weird characters which will influencestrcat(s, indent);
.if (j > 0)
to give one whole Btree graph.free_node
function to ensure no crash due to the memory leak with many iterations.