If I parse (using the libcmark library) a set of files using:
cmark_node* doc = cmark_parse_file(fp, CMARK_OPT_DEFAULT);
I see a potential memory leak because doc
is never freed.
Is it true?
If yes, seems cmark_document_free()
is missing from the library, or should I simply call cmark_node_free(doc);
? If this is indeed the case, I suggest to add a note to the documentation saying that this last routine releases the node and all its children.
Please help me clarify.
Thanks a lot!
mario
Yes, use cmark_node_free
to free the document node when you’re finished with it.
I’ll add something to the man page that makes it clearer that cmark_node_free
frees a node’s children too.