=================================================================== RCS file: /cvs/mandoc/compat_stringlist.c,v retrieving revision 1.1.1.1 retrieving revision 1.5 diff -u -p -r1.1.1.1 -r1.5 --- mandoc/compat_stringlist.c 2015/05/20 20:55:04 1.1.1.1 +++ mandoc/compat_stringlist.c 2015/05/21 00:13:43 1.5 @@ -1,5 +1,14 @@ +#include "config.h" + +#if HAVE_STRINGLIST + +int dummy; + +#else + +/* $Id: compat_stringlist.c,v 1.5 2015/05/21 00:13:43 schwarze Exp $ */ /* - * Copyright (c) 1994 Christos Zoulas + * Copyright (c) 1994 Christos Zoulas * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -10,8 +19,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -26,19 +33,10 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $"; -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD$"); - -#include "namespace.h" -#include -#include #include #include -#include -#include "un-namespace.h" +#include +#include "compat_stringlist.h" #define _SL_CHUNKSIZE 20 @@ -52,13 +50,13 @@ sl_init(void) sl = malloc(sizeof(StringList)); if (sl == NULL) - _err(1, "stringlist: %m"); + err(1, "stringlist"); sl->sl_cur = 0; sl->sl_max = _SL_CHUNKSIZE; - sl->sl_str = malloc(sl->sl_max * sizeof(char *)); + sl->sl_str = reallocarray(NULL, sl->sl_max, sizeof(char *)); if (sl->sl_str == NULL) - _err(1, "stringlist: %m"); + err(1, "stringlist"); return sl; } @@ -71,7 +69,8 @@ sl_add(StringList *sl, char *name) { if (sl->sl_cur == sl->sl_max - 1) { sl->sl_max += _SL_CHUNKSIZE; - sl->sl_str = reallocf(sl->sl_str, sl->sl_max * sizeof(char *)); + sl->sl_str = reallocarray(sl->sl_str, + sl->sl_max, sizeof(char *)); if (sl->sl_str == NULL) return (-1); } @@ -114,3 +113,5 @@ sl_find(StringList *sl, const char *name) return NULL; } + +#endif