[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.1 and 1.2

version 1.1, 2007/05/29 18:24:56 version 1.2, 2009/06/07 08:39:13
Line 36 
Line 36 
 }  }
   
 void *  void *
   xcalloc(size_t nmemb, size_t size)
   {
           void *ptr;
   
           if (size == 0 || nmemb == 0)
                   errx(1, "xcalloc: zero size");
           if (SIZE_MAX / nmemb < size)
                   errx(1, "xcalloc: nmemb * size > SIZE_MAX");
           ptr = calloc(nmemb, size);
           if (ptr == NULL)
                   errx(1, "xcalloc: out of memory (allocating %lu bytes)",
                       (u_long)(size * nmemb));
           return ptr;
   }
   
   void *
 xrealloc(void *ptr, size_t nmemb, size_t size)  xrealloc(void *ptr, size_t nmemb, size_t size)
 {  {
         void *new_ptr;          void *new_ptr;
Line 43 
Line 59 
   
         if (new_size == 0)          if (new_size == 0)
                 errx(2, NULL);                  errx(2, NULL);
         if (SIZE_T_MAX / nmemb < size)          if (SIZE_MAX / nmemb < size)
                 errx(2, NULL);                  errx(2, NULL);
         if (ptr == NULL)          if (ptr == NULL)
                 new_ptr = malloc(new_size);                  new_ptr = malloc(new_size);

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