[BACK]Return to compat_stringlist.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/compat_stringlist.c between version 1.2 and 1.7

version 1.2, 2015/05/20 22:22:59 version 1.7, 2020/06/15 01:37:15
Line 1 
Line 1 
 /*      $Id$    */  /* $Id$ */
 /*  /*
  * Copyright (c) 1994 Christos Zoulas <christos@netbsd.org>   * Copyright (c) 1994 Christos Zoulas <christos@netbsd.org>
  * All rights reserved.   * All rights reserved.
Line 11 
Line 11 
  * 2. Redistributions in binary form must reproduce the above copyright   * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the   *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.   *    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   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED   * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Line 26 
Line 24 
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.   * SUCH DAMAGE.
  */   */
   #include "config.h"
   
   #if HAVE_ERR
 #include <err.h>  #include <err.h>
   #endif
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include "compat_stringlist.h"  #include "compat_stringlist.h"
Line 48  sl_init(void)
Line 49  sl_init(void)
   
         sl->sl_cur = 0;          sl->sl_cur = 0;
         sl->sl_max = _SL_CHUNKSIZE;          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)          if (sl->sl_str == NULL)
                 err(1, "stringlist");                  err(1, "stringlist");
         return sl;          return sl;
Line 63  sl_add(StringList *sl, char *name)
Line 64  sl_add(StringList *sl, char *name)
 {  {
         if (sl->sl_cur == sl->sl_max - 1) {          if (sl->sl_cur == sl->sl_max - 1) {
                 sl->sl_max += _SL_CHUNKSIZE;                  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)                  if (sl->sl_str == NULL)
                         return (-1);                          return (-1);
         }          }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.7

CVSweb