diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-27 12:43:02 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-27 12:43:02 +0000 |
commit | 28d410a5b5d16d8adbf96aaae4ef71d0ae938144 (patch) | |
tree | c520b69d0c306ab2b613afe1046be2cdb4f5536e | |
parent | 41fb753e38e93d33d278d5b1ec34681285bc19f6 (diff) | |
download | mandoc-28d410a5b5d16d8adbf96aaae4ef71d0ae938144.tar.gz mandoc-28d410a5b5d16d8adbf96aaae4ef71d0ae938144.tar.zst mandoc-28d410a5b5d16d8adbf96aaae4ef71d0ae938144.zip |
Simply word allocation in libmdoc and libman.
-rw-r--r-- | man.c | 11 | ||||
-rw-r--r-- | mdoc.c | 11 |
2 files changed, 4 insertions, 18 deletions
@@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.109 2011/07/21 10:24:35 kristaps Exp $ */ +/* $Id: man.c,v 1.110 2011/07/27 12:43:02 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -320,16 +320,9 @@ 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(m, 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); + n->string = mandoc_strdup(word); if ( ! man_node_append(m, n)) return(0); @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.193 2011/07/27 12:41:02 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.194 2011/07/27 12:43:02 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -568,16 +568,9 @@ int mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p) { struct mdoc_node *n; - size_t sv, len; - - len = strlen(p); n = node_alloc(m, line, pos, MDOC_MAX, MDOC_TEXT); - n->string = mandoc_malloc(len + 1); - sv = strlcpy(n->string, p, len + 1); - - /* Prohibit truncation. */ - assert(sv < len + 1); + n->string = mandoc_strdup(p); if ( ! node_append(m, n)) return(0); |