Introduce a xreallocarray and convert a few xcalloc instances that do

not require zero'ing.
This commit is contained in:
okan
2015-03-28 23:12:47 +00:00
parent 0bbe0ad98c
commit a4a414b68b
4 changed files with 18 additions and 5 deletions

View File

@ -61,6 +61,18 @@ xcalloc(size_t no, size_t siz)
return(p);
}
void *
xreallocarray(void *ptr, size_t nmemb, size_t size)
{
void *p;
p = reallocarray(ptr, nmemb, size);
if (p == NULL)
errx(1, "xreallocarray: out of memory (new_size %zu bytes)",
nmemb * size);
return(p);
}
char *
xstrdup(const char *str)
{