chriseidhof / commonmark-swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leak in markdownToHtml?

ole opened this issue · comments

The documentation for cmark_markdown_to_html states:

It is the caller's responsibility to free the returned buffer.

Does this mean we have a memory leak in markdownToHtml? String.init(cString:) copies the buffer, so it seems we need to free it, right?

func markdownToHtml(string: String) -> String {
    let outString = cmark_markdown_to_html(string, string.utf8.count, 0)!
    return String(cString: outString)
}