From 75b48c5938f5984dbcf79a579d15c9cbd6447d12 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 18 Jan 2020 23:37:32 +0100 Subject: Use C string instead of chunk for custom block contents Reduces size of struct cmark_node by 8 bytes. --- src/node.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/node.c') diff --git a/src/node.c b/src/node.c index f67d07e..1e1f0e0 100644 --- a/src/node.c +++ b/src/node.c @@ -125,8 +125,8 @@ static void S_free_nodes(cmark_node *e) { break; case CMARK_NODE_CUSTOM_BLOCK: case CMARK_NODE_CUSTOM_INLINE: - cmark_chunk_free(NODE_MEM(e), &e->as.custom.on_enter); - cmark_chunk_free(NODE_MEM(e), &e->as.custom.on_exit); + NODE_MEM(e)->free(e->as.custom.on_enter); + NODE_MEM(e)->free(e->as.custom.on_exit); break; default: break; @@ -571,7 +571,7 @@ const char *cmark_node_get_on_enter(cmark_node *node) { switch (node->type) { case CMARK_NODE_CUSTOM_INLINE: case CMARK_NODE_CUSTOM_BLOCK: - return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.custom.on_enter); + return node->as.custom.on_enter ? (char *)node->as.custom.on_enter : ""; default: break; } @@ -587,7 +587,7 @@ int cmark_node_set_on_enter(cmark_node *node, const char *on_enter) { switch (node->type) { case CMARK_NODE_CUSTOM_INLINE: case CMARK_NODE_CUSTOM_BLOCK: - cmark_chunk_set_cstr(NODE_MEM(node), &node->as.custom.on_enter, on_enter); + cmark_set_cstr(NODE_MEM(node), &node->as.custom.on_enter, on_enter); return 1; default: break; @@ -604,7 +604,7 @@ const char *cmark_node_get_on_exit(cmark_node *node) { switch (node->type) { case CMARK_NODE_CUSTOM_INLINE: case CMARK_NODE_CUSTOM_BLOCK: - return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.custom.on_exit); + return node->as.custom.on_exit ? (char *)node->as.custom.on_exit : ""; default: break; } @@ -620,7 +620,7 @@ int cmark_node_set_on_exit(cmark_node *node, const char *on_exit) { switch (node->type) { case CMARK_NODE_CUSTOM_INLINE: case CMARK_NODE_CUSTOM_BLOCK: - cmark_chunk_set_cstr(NODE_MEM(node), &node->as.custom.on_exit, on_exit); + cmark_set_cstr(NODE_MEM(node), &node->as.custom.on_exit, on_exit); return 1; default: break; -- cgit v1.2.3