From 48343e99b8bb27fdc7763e521ea7e651ecc7a7ba Mon Sep 17 00:00:00 2001 From: NRK Date: Thu, 3 Feb 2022 14:22:25 +0600 Subject: code-style: prefer calloc over malloc+memset --- util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index 71ff7be..ef0ec43 100644 --- a/util.c +++ b/util.c @@ -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); -- cgit v1.2.3-70-g09d2