=================================================================== RCS file: /cvs/docbook2mdoc/statistics.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -p -r1.36 -r1.37 --- docbook2mdoc/statistics.c 2019/04/25 17:57:59 1.36 +++ docbook2mdoc/statistics.c 2019/04/28 15:03:29 1.37 @@ -1,4 +1,4 @@ -/* $Id: statistics.c,v 1.36 2019/04/25 17:57:59 schwarze Exp $ */ +/* $Id: statistics.c,v 1.37 2019/04/28 15:03:29 schwarze Exp $ */ /* * Copyright (c) 2019 Ingo Schwarze * @@ -14,6 +14,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include #include #include @@ -24,6 +26,8 @@ #include #include +#include "xmalloc.h" + /* * Count parent-child element relations in a corpus of DocBook documents. * @@ -125,19 +129,13 @@ table_add(const char *parent, const char *child) if (tablei == tablesz) { tablesz += 64; - table = reallocarray(table, tablesz, sizeof(*table)); - if (table == NULL) - err(1, NULL); + table = xreallocarray(table, tablesz, sizeof(*table)); } /* Add a new entry to the table. */ - if ((table[tablei].parent = strdup(parent)) == NULL) - err(1, NULL); - if (child == NULL) - table[tablei].child = NULL; - else if ((table[tablei].child = strdup(child)) == NULL) - err(1, NULL); + table[tablei].parent = xstrdup(parent); + table[tablei].child = child == NULL ? NULL : xstrdup(child); table[tablei++].count = init_done ? 1 : -1; } @@ -152,12 +150,9 @@ stack_push(const char *name) if (stacki == stacksz) { stacksz += 8; - stack = reallocarray(stack, stacksz, sizeof(*stack)); - if (stack == NULL) - err(1, NULL); + stack = xreallocarray(stack, stacksz, sizeof(*stack)); } - if ((stack[stacki++] = strdup(name)) == NULL) - err(1, NULL); + stack[stacki++] = xstrdup(name); } /*