diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2020-01-18 23:12:37 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-01-23 08:25:54 -0800 |
commit | b237924585e61532ada774bf9e70eadff00666dc (patch) | |
tree | 4355e86e19736d1eeffd905cdbc2d2b6ea7a6430 /src/node.c | |
parent | 3acbdf0965859c55fa36c65a4c0e17e92012687c (diff) |
Use C string instead of chunk for link URL and title
Use zero-terminated C strings instead of cmark_chunks without storing
the length. This introduces a few additional strlen computations,
but overhead should be low.
Allows to reduce size of struct cmark_node later.
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -120,8 +120,8 @@ static void S_free_nodes(cmark_node *e) { break; case CMARK_NODE_LINK: case CMARK_NODE_IMAGE: - cmark_chunk_free(NODE_MEM(e), &e->as.link.url); - cmark_chunk_free(NODE_MEM(e), &e->as.link.title); + NODE_MEM(e)->free(e->as.link.url); + NODE_MEM(e)->free(e->as.link.title); break; case CMARK_NODE_CUSTOM_BLOCK: case CMARK_NODE_CUSTOM_INLINE: @@ -505,7 +505,7 @@ const char *cmark_node_get_url(cmark_node *node) { switch (node->type) { case CMARK_NODE_LINK: case CMARK_NODE_IMAGE: - return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.link.url); + return node->as.link.url ? (char *)node->as.link.url : ""; default: break; } @@ -521,7 +521,7 @@ int cmark_node_set_url(cmark_node *node, const char *url) { switch (node->type) { case CMARK_NODE_LINK: case CMARK_NODE_IMAGE: - cmark_chunk_set_cstr(NODE_MEM(node), &node->as.link.url, url); + cmark_set_cstr(NODE_MEM(node), &node->as.link.url, url); return 1; default: break; @@ -538,7 +538,7 @@ const char *cmark_node_get_title(cmark_node *node) { switch (node->type) { case CMARK_NODE_LINK: case CMARK_NODE_IMAGE: - return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.link.title); + return node->as.link.title ? (char *)node->as.link.title : ""; default: break; } @@ -554,7 +554,7 @@ int cmark_node_set_title(cmark_node *node, const char *title) { switch (node->type) { case CMARK_NODE_LINK: case CMARK_NODE_IMAGE: - cmark_chunk_set_cstr(NODE_MEM(node), &node->as.link.title, title); + cmark_set_cstr(NODE_MEM(node), &node->as.link.title, title); return 1; default: break; |