[BACK]Return to xmalloc.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rcs

Diff for /src/usr.bin/rcs/xmalloc.c between version 1.5 and 1.6

version 1.5, 2014/09/27 15:16:36 version 1.6, 2014/12/01 21:58:46
Line 54 
Line 54 
 }  }
   
 void *  void *
 xrealloc(void *ptr, size_t nmemb, size_t size)  xreallocarray(void *ptr, size_t nmemb, size_t size)
 {  {
         void *new_ptr;          void *new_ptr;
         size_t new_size = nmemb * size;  
   
         if (new_size == 0)          new_ptr = reallocarray(ptr, nmemb, size);
                 errx(1, "xrealloc: zero size");  
         if (SIZE_MAX / nmemb < size)  
                 errx(1, "xrealloc: nmemb * size > SIZE_MAX");  
         if (ptr == NULL)  
                 new_ptr = malloc(new_size);  
         else  
                 new_ptr = realloc(ptr, new_size);  
         if (new_ptr == NULL)          if (new_ptr == NULL)
                 errx(1, "xrealloc: out of memory (new_size %zu bytes)",                  errx(1, "xrealloc: out of memory (new_size %zu bytes)",
                     new_size);                      nmemb * size);
         return new_ptr;          return new_ptr;
 }  }
   

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