=================================================================== RCS file: /cvs/docbook2mdoc/parse.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -p -r1.33 -r1.34 --- docbook2mdoc/parse.c 2019/04/12 04:17:11 1.33 +++ docbook2mdoc/parse.c 2019/04/12 04:39:24 1.34 @@ -1,4 +1,4 @@ -/* $Id: parse.c,v 1.33 2019/04/12 04:17:11 schwarze Exp $ */ +/* $Id: parse.c,v 1.34 2019/04/12 04:39:24 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * Copyright (c) 2019 Ingo Schwarze @@ -337,14 +337,10 @@ xml_char(struct parse *p, const char *word, int sz) } if (n->node != NODE_TEXT) { - if ((n = calloc(1, sizeof(*n))) == NULL) + if ((n = pnode_alloc(p->cur)) == NULL) fatal(p); n->node = NODE_TEXT; n->spc = (p->flags & PFLAG_SPC) != 0; - n->parent = p->cur; - TAILQ_INIT(&n->childq); - TAILQ_INIT(&n->attrq); - TAILQ_INSERT_TAIL(&p->cur->childq, n, child); p->cur = n; } @@ -440,15 +436,11 @@ xml_entity(struct parse *p, const char *name) } /* Create, append, and close out an entity node. */ - if ((n = calloc(1, sizeof(*n))) == NULL || + if ((n = pnode_alloc(p->cur)) == NULL || (n->b = strdup(entity->roff)) == NULL) fatal(p); n->node = NODE_ESCAPE; n->spc = (p->flags & PFLAG_SPC) != 0; - n->parent = p->cur; - TAILQ_INIT(&n->childq); - TAILQ_INIT(&n->attrq); - TAILQ_INSERT_TAIL(&p->cur->childq, n, child); p->flags &= ~PFLAG_SPC; } @@ -504,7 +496,7 @@ xml_elem_start(struct parse *p, const char *name) if (p->tree->flags & TREE_CLOSED && p->cur->parent == NULL) warn_msg(p, "element after end of document: <%s>", name); - if ((n = calloc(1, sizeof(*n))) == NULL) + if ((n = pnode_alloc(p->cur)) == NULL) fatal(p); /* @@ -556,13 +548,6 @@ xml_elem_start(struct parse *p, const char *name) n->spc = (p->flags & PFLAG_SPC) != 0; break; } - n->parent = p->cur; - TAILQ_INIT(&n->childq); - TAILQ_INIT(&n->attrq); - - if (p->cur != NULL) - TAILQ_INSERT_TAIL(&p->cur->childq, n, child); - p->cur = n; if (n->node == NODE_DOCTYPE) { if (p->doctype == NULL)