Skip to content

Commit

Permalink
Removed check for same mem allocator in S_can_contain.
Browse files Browse the repository at this point in the history
This is too strict, as it prevents the use of dynamically
loaded extensions: see
commonmark#123 (comment).

Documented in man page and public header that one should use the same
memory allocator for every node in a tree.
  • Loading branch information
jgm committed Jun 23, 2016
1 parent 66ee8c4 commit 2553228
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/cmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ typedef struct cmark_mem {
CMARK_EXPORT cmark_node *cmark_node_new(cmark_node_type type);

/** Same as `cmark_node_new`, but explicitly listing the memory
* allocator used to allocate the node
* allocator used to allocate the node. Note: be sure to use the same
* allocator for every node in a tree, or bad things can happen.
*/
CMARK_EXPORT cmark_node *cmark_node_new_with_mem(cmark_node_type type, cmark_mem *mem);

Expand Down
3 changes: 0 additions & 3 deletions src/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ static bool S_can_contain(cmark_node *node, cmark_node *child) {
if (node == NULL || child == NULL) {
return false;
}
if (NODE_MEM(node) != NODE_MEM(child)) {
return 0;
}

// Verify that child is not an ancestor of node or equal to node.
cur = node;
Expand Down

0 comments on commit 2553228

Please sign in to comment.