summaryrefslogtreecommitdiff
path: root/src/iterator.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2016-05-27 16:55:16 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2016-06-06 15:39:05 -0700
commit25429c96f6554ffac415f9d865934b1183f3398e (patch)
tree84d4eef404e99ff9e88d96a86d348a863d7c466f /src/iterator.c
parentab6c81b960e86b26c7fda366f51ff29d1683a555 (diff)
cmark: Implement support for custom allocators
Diffstat (limited to 'src/iterator.c')
-rw-r--r--src/iterator.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/iterator.c b/src/iterator.c
index 40287f5..24423a2 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -16,7 +16,9 @@ cmark_iter *cmark_iter_new(cmark_node *root) {
if (root == NULL) {
return NULL;
}
- cmark_iter *iter = (cmark_iter *)cmark_calloc(1, sizeof(cmark_iter));
+ cmark_mem *mem = root->content.mem;
+ cmark_iter *iter = (cmark_iter *)mem->calloc(1, sizeof(cmark_iter));
+ iter->mem = mem;
iter->root = root;
iter->cur.ev_type = CMARK_EVENT_NONE;
iter->cur.node = NULL;
@@ -25,7 +27,7 @@ cmark_iter *cmark_iter_new(cmark_node *root) {
return iter;
}
-void cmark_iter_free(cmark_iter *iter) { free(iter); }
+void cmark_iter_free(cmark_iter *iter) { iter->mem->free(iter); }
static bool S_is_leaf(cmark_node *node) {
return ((1 << node->type) & S_leaf_mask) != 0;
@@ -90,7 +92,7 @@ void cmark_consolidate_text_nodes(cmark_node *root) {
return;
}
cmark_iter *iter = cmark_iter_new(root);
- cmark_strbuf buf = GH_BUF_INIT;
+ cmark_strbuf buf = CMARK_BUF_INIT(iter->mem);
cmark_event_type ev_type;
cmark_node *cur, *tmp, *next;
@@ -108,7 +110,7 @@ void cmark_consolidate_text_nodes(cmark_node *root) {
cmark_node_free(tmp);
tmp = next;
}
- cmark_chunk_free(&cur->as.literal);
+ cmark_chunk_free(iter->mem, &cur->as.literal);
cur->as.literal = cmark_chunk_buf_detach(&buf);
}
}