X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/ea3a546595c994f7d63049af16eecab1660ef4fa..f5330ed0a9932ca87b5c5c013a54a98d784a8df2:/compat_stringlist.c diff --git a/compat_stringlist.c b/compat_stringlist.c index 2b26e200..17eba772 100644 --- a/compat_stringlist.c +++ b/compat_stringlist.c @@ -1,4 +1,12 @@ -/* $Id: compat_stringlist.c,v 1.2 2015/05/20 22:22:59 schwarze Exp $ */ +#include "config.h" + +#if HAVE_STRINGLIST + +int dummy; + +#else + +/* $Id: compat_stringlist.c,v 1.6 2015/11/07 14:22:29 schwarze Exp $ */ /* * Copyright (c) 1994 Christos Zoulas * All rights reserved. @@ -11,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 @@ -27,7 +33,9 @@ * SUCH DAMAGE. */ +#if HAVE_ERR #include +#endif #include #include #include "compat_stringlist.h" @@ -48,7 +56,7 @@ sl_init(void) 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"); return sl; @@ -63,7 +71,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); } @@ -106,3 +115,5 @@ sl_find(StringList *sl, const char *name) return NULL; } + +#endif