diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-12-22 11:15:16 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-12-22 11:15:16 +0000 |
commit | 5e8dea30d01017a3651dedc1f6eda3d2b1e6f8d1 (patch) | |
tree | c8b375d34bff877a170de8f810c1516d101a37e3 /mdoc.c | |
parent | a227976c4a6d61ca51f3b2ae7f15ee46a39ac235 (diff) | |
download | mandoc-5e8dea30d01017a3651dedc1f6eda3d2b1e6f8d1.tar.gz mandoc-5e8dea30d01017a3651dedc1f6eda3d2b1e6f8d1.tar.zst mandoc-5e8dea30d01017a3651dedc1f6eda3d2b1e6f8d1.zip |
Implement reference-counted version of original union mdoc_data. This
simplifies clean-up and allows for more types without extra hassle.
Also made in-line literal types in -T[x]html use CODE instead of SPAN to
match how literal blocks use PRE.
Diffstat (limited to 'mdoc.c')
-rw-r--r-- | mdoc.c | 30 |
1 files changed, 7 insertions, 23 deletions
@@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.170 2010/12/16 17:14:48 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.171 2010/12/22 11:15:16 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -511,24 +511,8 @@ static void mdoc_node_free(struct mdoc_node *p) { - /* - * XXX: if these end up being problematic in terms of memory - * management and dereferencing freed blocks, then make them - * into reference-counted double-pointers. - */ - - if (MDOC_Bd == p->tok && MDOC_BLOCK == p->type) - if (p->data.Bd) - free(p->data.Bd); - if (MDOC_Bl == p->tok && MDOC_BLOCK == p->type) - if (p->data.Bl) - free(p->data.Bl); - if (MDOC_Bf == p->tok && MDOC_HEAD == p->type) - if (p->data.Bf) - free(p->data.Bf); - if (MDOC_An == p->tok) - if (p->data.An) - free(p->data.An); + if (p->norm && 0 == --(p->norm->refcnt)) + free(p->norm); if (p->string) free(p->string); @@ -624,7 +608,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) */ if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->data.Bl->type) { + LIST_column == n->norm->d.Bl.type) { /* `Bl' is open without any children. */ m->flags |= MDOC_FREECOL; return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); @@ -633,7 +617,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs) if (MDOC_It == n->tok && MDOC_BLOCK == n->type && NULL != n->parent && MDOC_Bl == n->parent->tok && - LIST_column == n->parent->data.Bl->type) { + LIST_column == n->parent->norm->d.Bl.type) { /* `Bl' has block-level `It' children. */ m->flags |= MDOC_FREECOL; return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); @@ -814,7 +798,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) */ if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->data.Bl->type) { + LIST_column == n->norm->d.Bl.type) { m->flags |= MDOC_FREECOL; if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) goto err; @@ -830,7 +814,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) if (MDOC_It == n->tok && MDOC_BLOCK == n->type && NULL != n->parent && MDOC_Bl == n->parent->tok && - LIST_column == n->parent->data.Bl->type) { + LIST_column == n->parent->norm->d.Bl.type) { m->flags |= MDOC_FREECOL; if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) goto err; |