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

Diff for /src/usr.bin/file/xmalloc.c between version 1.2 and 1.3

version 1.2, 2015/06/17 18:51:11 version 1.3, 2015/11/17 18:25:03
Line 31 
Line 31 
                 errx(1, "xmalloc: zero size");                  errx(1, "xmalloc: zero size");
         ptr = malloc(size);          ptr = malloc(size);
         if (ptr == NULL)          if (ptr == NULL)
                 errx(1,                  err(1, "xmalloc: allocating %zu bytes", size);
                     "xmalloc: out of memory (allocating %zu bytes)",  
                     size);  
         return ptr;          return ptr;
 }  }
   
Line 44 
Line 42 
   
         if (size == 0 || nmemb == 0)          if (size == 0 || nmemb == 0)
                 errx(1, "xcalloc: zero size");                  errx(1, "xcalloc: zero size");
         if (SIZE_MAX / nmemb < size)  
                 errx(1, "xcalloc: nmemb * size > SIZE_MAX");  
         ptr = calloc(nmemb, size);          ptr = calloc(nmemb, size);
         if (ptr == NULL)          if (ptr == NULL)
                 errx(1, "xcalloc: out of memory (allocating %zu bytes)",                  err(1, "xcalloc: allocating %zu * %zu bytes", nmemb, size);
                     (size * nmemb));  
         return ptr;          return ptr;
 }  }
   
Line 60 
Line 55 
   
         new_ptr = reallocarray(ptr, nmemb, size);          new_ptr = reallocarray(ptr, nmemb, size);
         if (new_ptr == NULL)          if (new_ptr == NULL)
                 errx(1, "xreallocarray: out of memory (new_size %zu bytes)",                  err(1, "xreallocarray: allocating %zu * %zu bytes",
                     nmemb * size);                      nmemb, size);
         return new_ptr;          return new_ptr;
 }  }
   
Line 86 
Line 81 
         va_end(ap);          va_end(ap);
   
         if (i < 0 || *ret == NULL)          if (i < 0 || *ret == NULL)
                 errx(1, "xasprintf: could not allocate memory");                  err(1, "xasprintf");
   
         return (i);          return i;
 }  }

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