Line | Count | Source (jump to first uncovered line) |
1 | | #include <stdlib.h> |
2 | | #include <assert.h> |
3 | | #include <stdio.h> |
4 | | #include "node.h" |
5 | | #include "houdini.h" |
6 | | #include "cmark.h" |
7 | | #include "buffer.h" |
8 | | |
9 | 0 | int cmark_version(void) { return CMARK_VERSION; } |
10 | | |
11 | 0 | const char *cmark_version_string(void) { return CMARK_VERSION_STRING; } |
12 | | |
13 | 21.1M | static void *xcalloc(size_t nmem, size_t size) { |
14 | 21.1M | void *ptr = calloc(nmem, size); |
15 | 21.1M | if (!ptr) { |
16 | 0 | fprintf(stderr, "[cmark] calloc returned null pointer, aborting\n"); |
17 | 0 | abort(); |
18 | 0 | } |
19 | 21.1M | return ptr; |
20 | 21.1M | } |
21 | | |
22 | 9.57M | static void *xrealloc(void *ptr, size_t size) { |
23 | 9.57M | void *new_ptr = realloc(ptr, size); |
24 | 9.57M | if (!new_ptr) { |
25 | 0 | fprintf(stderr, "[cmark] realloc returned null pointer, aborting\n"); |
26 | 0 | abort(); |
27 | 0 | } |
28 | 9.57M | return new_ptr; |
29 | 9.57M | } |
30 | | |
31 | | cmark_mem DEFAULT_MEM_ALLOCATOR = {xcalloc, xrealloc, free}; |
32 | | |
33 | 21.2M | cmark_mem *cmark_get_default_mem_allocator(void) { |
34 | 21.2M | return &DEFAULT_MEM_ALLOCATOR; |
35 | 21.2M | } |
36 | | |
37 | | |
38 | 3.11k | char *cmark_markdown_to_html(const char *text, size_t len, int options) { |
39 | 3.11k | cmark_node *doc; |
40 | 3.11k | char *result; |
41 | | |
42 | 3.11k | doc = cmark_parse_document(text, len, options); |
43 | | |
44 | 3.11k | result = cmark_render_html(doc, options); |
45 | 3.11k | cmark_node_free(doc); |
46 | | |
47 | 3.11k | return result; |
48 | 3.11k | } |