From b237924585e61532ada774bf9e70eadff00666dc Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 18 Jan 2020 23:12:37 +0100 Subject: 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. --- src/xml.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/xml.c') diff --git a/src/xml.c b/src/xml.c index bd82f5f..4bede85 100644 --- a/src/xml.c +++ b/src/xml.c @@ -121,11 +121,14 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, case CMARK_NODE_LINK: case CMARK_NODE_IMAGE: cmark_strbuf_puts(xml, " destination=\""); - escape_xml(xml, node->as.link.url.data, node->as.link.url.len); - cmark_strbuf_putc(xml, '"'); - cmark_strbuf_puts(xml, " title=\""); - escape_xml(xml, node->as.link.title.data, node->as.link.title.len); + escape_xml(xml, node->as.link.url, strlen((char *)node->as.link.url)); cmark_strbuf_putc(xml, '"'); + if (node->as.link.title) { + cmark_strbuf_puts(xml, " title=\""); + escape_xml(xml, node->as.link.title, + strlen((char *)node->as.link.title)); + cmark_strbuf_putc(xml, '"'); + } break; default: break; -- cgit v1.2.3