diff options
author | NRK <nrk@disroot.org> | 2022-02-03 14:22:25 +0600 |
---|---|---|
committer | N-R-K <79544946+N-R-K@users.noreply.github.com> | 2022-02-17 06:16:19 +0000 |
commit | 48343e99b8bb27fdc7763e521ea7e651ecc7a7ba (patch) | |
tree | c541b394ebb9d03d8b51919eb6cadef917a819b3 /util.c | |
parent | 9cdeeab9b813a44ac6f23c0494626fa0f0727f42 (diff) |
code-style: prefer calloc over malloc+memset
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); |