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

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

version 1.5, 2015/02/05 12:59:57 version 1.6, 2015/04/29 04:00:25
Line 52 
Line 52 
 }  }
   
 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(2, "xrealloc: zero size");  
         if (SIZE_MAX / nmemb < size)  
                 errx(2, "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)
                 err(2, NULL);                  err(2, NULL);
         return new_ptr;          return new_ptr;

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