code-style: prefer calloc over malloc+memset

This commit is contained in:
NRK
2022-02-03 14:22:25 +06:00
committed by N-R-K
parent 9cdeeab9b8
commit 48343e99b8
4 changed files with 15 additions and 7 deletions

10
util.c
View File

@ -38,6 +38,16 @@ void* emalloc(size_t size)
return ptr;
}
void* ecalloc(size_t nmemb, size_t size)
{
void *ptr;
ptr = calloc(nmemb, size);
if (ptr == NULL)
error(EXIT_FAILURE, errno, NULL);
return ptr;
}
void* erealloc(void *ptr, size_t size)
{
ptr = realloc(ptr, size);