summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api_test/main.c4
-rw-r--r--man/man3/cmark.38
-rw-r--r--src/cmark.c5
-rw-r--r--src/cmark.h4
4 files changed, 19 insertions, 2 deletions
diff --git a/api_test/main.c b/api_test/main.c
index 994ee39..29346b7 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -320,7 +320,9 @@ static void iterator_delete(test_batch_runner *runner) {
"<p>a c</p>\n";
STR_EQ(runner, html, expected, "iterate and delete nodes");
- free(html);
+ cmark_mem *allocator = cmark_get_default_mem_allocator();
+
+ allocator->free(html);
cmark_iter_free(iter);
cmark_node_free(doc);
}
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
index 65ab6d6..e460244 100644
--- a/man/man3/cmark.3
+++ b/man/man3/cmark.3
@@ -1,4 +1,4 @@
-.TH cmark 3 "March 19, 2019" "LOCAL" "Library Functions Manual"
+.TH cmark 3 "February 09, 2020" "LOCAL" "Library Functions Manual"
.SH
NAME
.PP
@@ -115,6 +115,12 @@ typedef struct cmark_mem {
Defines the memory allocation functions to be used by CMark when parsing
and allocating a document tree
+.PP
+\fIcmark_mem *\f[] \fBcmark_get_default_mem_allocator\f[](\fI\f[])
+
+.PP
+Returns a pointer to the default memory allocator.
+
.SS
Creating and Destroying Nodes
diff --git a/src/cmark.c b/src/cmark.c
index d64237f..8bbca03 100644
--- a/src/cmark.c
+++ b/src/cmark.c
@@ -30,6 +30,11 @@ static void *xrealloc(void *ptr, size_t size) {
cmark_mem DEFAULT_MEM_ALLOCATOR = {xcalloc, xrealloc, free};
+cmark_mem *cmark_get_default_mem_allocator() {
+ return &DEFAULT_MEM_ALLOCATOR;
+}
+
+
char *cmark_markdown_to_html(const char *text, size_t len, int options) {
cmark_node *doc;
char *result;
diff --git a/src/cmark.h b/src/cmark.h
index 102aa6f..a37c185 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -100,6 +100,10 @@ typedef struct cmark_mem {
void (*free)(void *);
} cmark_mem;
+/** Returns a pointer to the default memory allocator.
+ */
+CMARK_EXPORT cmark_mem *cmark_get_default_mem_allocator();
+
/**
* ## Creating and Destroying Nodes
*/