diff options
Diffstat (limited to 'src/cmark.c')
-rw-r--r-- | src/cmark.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cmark.c b/src/cmark.c index 3491199..d5fef63 100644 --- a/src/cmark.c +++ b/src/cmark.c @@ -10,6 +10,20 @@ int cmark_version() { return CMARK_VERSION; } const char *cmark_version_string() { return CMARK_VERSION_STRING; } +static void *xcalloc(size_t nmem, size_t size) { + void *ptr = calloc(nmem, size); + if (!ptr) abort(); + return ptr; +} + +static void *xrealloc(void *ptr, size_t size) { + void *new_ptr = realloc(ptr, size); + if (!new_ptr) abort(); + return new_ptr; +} + +cmark_mem DEFAULT_MEM_ALLOCATOR = { xcalloc, xrealloc, free }; + char *cmark_markdown_to_html(const char *text, size_t len, int options) { cmark_node *doc; char *result; |