From f3f50b29d615d2678d8047dc277b108cc5143167 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 19 Jan 2020 13:46:10 +0100 Subject: Rearrange struct cmark_node Introduce multi-purpose data/len members in struct cmark_node. This is mainly used to store literal text for inlines, code and HTML blocks. Move the content strbuf for blocks from cmark_node to cmark_parser. When finalizing nodes that allow inlines (paragraphs and headings), detach the strbuf and store the block content in the node's data/len members. Free the block content after processing inlines. Reduces size of struct cmark_node by 8 bytes. --- src/xml.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/xml.c') diff --git a/src/xml.c b/src/xml.c index 48b4e91..9306141 100644 --- a/src/xml.c +++ b/src/xml.c @@ -61,7 +61,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, case CMARK_NODE_HTML_BLOCK: case CMARK_NODE_HTML_INLINE: cmark_strbuf_puts(xml, " xml:space=\"preserve\">"); - escape_xml(xml, node->as.literal.data, node->as.literal.len); + escape_xml(xml, node->data, node->len); cmark_strbuf_puts(xml, ""); - escape_xml(xml, node->as.code.literal, - strlen((char *)node->as.code.literal)); + escape_xml(xml, node->data, node->len); cmark_strbuf_puts(xml, "mem); cmark_event_type ev_type; cmark_node *cur; struct render_state state = {&xml, 0}; -- cgit v1.2.3