From fdbdbf7ecc8597d2b6ae329ecbdabebaf0793fba Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 9 Feb 2020 09:03:16 -0800 Subject: Add cmark_get_default_mem_allocator(). API change: This adds a new exported function in cmark.h. Closes #330. --- src/cmark.c | 5 +++++ src/cmark.h | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'src') 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 */ -- cgit v1.2.3