-
-static struct man_node *
-man_node_alloc(int line, int pos, enum man_type type, enum mant tok)
-{
- struct man_node *p;
-
- p = mandoc_calloc(1, sizeof(struct man_node));
- p->line = line;
- p->pos = pos;
- p->type = type;
- p->tok = tok;
- return(p);
-}
-
-
-int
-man_elem_alloc(struct man *m, int line, int pos, enum mant tok)
-{
- struct man_node *p;
-
- p = man_node_alloc(line, pos, MAN_ELEM, tok);
- if ( ! man_node_append(m, p))
- return(0);
- m->next = MAN_NEXT_CHILD;
- return(1);
-}
-
-
-int
-man_head_alloc(struct man *m, int line, int pos, enum mant tok)
-{
- struct man_node *p;
-
- p = man_node_alloc(line, pos, MAN_HEAD, tok);
- if ( ! man_node_append(m, p))
- return(0);
- m->next = MAN_NEXT_CHILD;
- return(1);
-}
-
-
-int
-man_body_alloc(struct man *m, int line, int pos, enum mant tok)
-{
- struct man_node *p;
-
- p = man_node_alloc(line, pos, MAN_BODY, tok);
- if ( ! man_node_append(m, p))
- return(0);
- m->next = MAN_NEXT_CHILD;
- return(1);
-}
-
-
-int
-man_block_alloc(struct man *m, int line, int pos, enum mant tok)
-{
- struct man_node *p;
-
- p = man_node_alloc(line, pos, MAN_BLOCK, tok);
- if ( ! man_node_append(m, p))
- return(0);
- m->next = MAN_NEXT_CHILD;
- return(1);
-}
-
-
-int
-man_word_alloc(struct man *m, int line, int pos, const char *word)
-{
- struct man_node *n;
- size_t sv, len;
-
- len = strlen(word);
-
- n = man_node_alloc(line, pos, MAN_TEXT, MAN_MAX);
- n->string = mandoc_malloc(len + 1);
- sv = strlcpy(n->string, word, len + 1);
-
- /* Prohibit truncation. */
- assert(sv < len + 1);
-
- if ( ! man_node_append(m, n))
- return(0);
-
- m->next = MAN_NEXT_SIBLING;
- return(1);
-}
-
-
-/*
- * Free all of the resources held by a node. This does NOT unlink a
- * node from its context; for that, see man_node_unlink().
- */
-static void
-man_node_free(struct man_node *p)
-{
-
- if (p->string)
- free(p->string);
- free(p);
-}
-
-
-void
-man_node_delete(struct man *m, struct man_node *p)
-{
-
- while (p->child)
- man_node_delete(m, p->child);
-
- man_node_unlink(m, p);
- man_node_free(p);
-}
-
-