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

Diff for /mandoc/mandoc_aux.c between version 1.6 and 1.11

version 1.6, 2015/10/11 21:12:54 version 1.11, 2018/02/07 20:04:57
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 19 
Line 19 
   
 #include <sys/types.h>  #include <sys/types.h>
   
   #if HAVE_ERR
 #include <err.h>  #include <err.h>
   #endif
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <stdio.h>  #include <stdio.h>
Line 28 
Line 30 
 #include "mandoc.h"  #include "mandoc.h"
 #include "mandoc_aux.h"  #include "mandoc_aux.h"
   
 #if !HAVE_PROGNAME  
 const char *mandoc_progname;  
 #endif  
   
 int  int
 mandoc_asprintf(char **dest, const char *fmt, ...)  mandoc_asprintf(char **dest, const char *fmt, ...)
Line 72  mandoc_malloc(size_t size)
Line 71  mandoc_malloc(size_t size)
 void *  void *
 mandoc_realloc(void *ptr, size_t size)  mandoc_realloc(void *ptr, size_t size)
 {  {
   
         ptr = realloc(ptr, size);          ptr = realloc(ptr, size);
         if (ptr == NULL)          if (ptr == NULL)
                 err((int)MANDOCLEVEL_SYSERR, NULL);                  err((int)MANDOCLEVEL_SYSERR, NULL);
Line 82  mandoc_realloc(void *ptr, size_t size)
Line 80  mandoc_realloc(void *ptr, size_t size)
 void *  void *
 mandoc_reallocarray(void *ptr, size_t num, size_t size)  mandoc_reallocarray(void *ptr, size_t num, size_t size)
 {  {
   
         ptr = reallocarray(ptr, num, size);          ptr = reallocarray(ptr, num, size);
         if (ptr == NULL)          if (ptr == NULL)
                 err((int)MANDOCLEVEL_SYSERR, NULL);                  err((int)MANDOCLEVEL_SYSERR, NULL);
         return ptr;          return ptr;
 }  }
   
   void *
   mandoc_recallocarray(void *ptr, size_t oldnum, size_t num, size_t size)
   {
           ptr = recallocarray(ptr, oldnum, num, size);
           if (ptr == NULL)
                   err((int)MANDOCLEVEL_SYSERR, NULL);
           return ptr;
   }
   
 char *  char *
 mandoc_strdup(const char *ptr)  mandoc_strdup(const char *ptr)
 {  {
         char    *p;          char    *p;
   
         p = strdup(ptr);          p = strdup(ptr);
         if (ptr == NULL)          if (p == NULL)
                 err((int)MANDOCLEVEL_SYSERR, NULL);                  err((int)MANDOCLEVEL_SYSERR, NULL);
         return p;          return p;
 }  }
Line 105  mandoc_strndup(const char *ptr, size_t sz)
Line 111  mandoc_strndup(const char *ptr, size_t sz)
 {  {
         char    *p;          char    *p;
   
         p = mandoc_malloc(sz + 1);          p = strndup(ptr, sz);
         memcpy(p, ptr, sz);          if (p == NULL)
         p[(int)sz] = '\0';                  err((int)MANDOCLEVEL_SYSERR, NULL);
         return p;          return p;
 }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.11

CVSweb