From 28d410a5b5d16d8adbf96aaae4ef71d0ae938144 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 27 Jul 2011 12:43:02 +0000 Subject: Simply word allocation in libmdoc and libman. --- man.c | 11 ++--------- mdoc.c | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/man.c b/man.c index 593777ac..9d480e10 100644 --- a/man.c +++ b/man.c @@ -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 * @@ -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); diff --git a/mdoc.c b/mdoc.c index cdeb88bf..2808326a 100644 --- a/mdoc.c +++ b/mdoc.c @@ -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 * Copyright (c) 2010 Ingo Schwarze @@ -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); -- cgit v1.2.3