sfm

simple file manager
git clone git://git.afify.dev/sfm
Log | Files | Refs | README | LICENSE

commit e4a06397f0081b59890477d325fa96fd1df0f508
parent 98dc9a586c85fde66476016b9ac70668026a569d
Author: afify <hassan@afify.dev>
Date:   Mon, 13 Jul 2020 21:10:21 +0300

[feat] add erealloc()

Diffstat:
Mutil.c | 9+++++++++
Mutil.h | 1+
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/util.c b/util.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ +#include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -15,6 +16,14 @@ ecalloc(size_t nmemb, size_t size) return p; } +void * +erealloc(void *p, size_t len) +{ + if ((p = realloc(p, len)) == NULL) + die("realloc: %s\n", strerror(errno)); + return p; +} + void die(const char *fmt, ...) { diff --git a/util.h b/util.h @@ -10,6 +10,7 @@ #define FAIL_IF(EXP, MSG) {if(EXP){fprintf(stderr, "[\033[31mFAILED %d\033[0m] %s\n", __LINE__, MSG);exit(EXIT_FAILURE);}} void *ecalloc(size_t, size_t); +void *erealloc(void*, size_t); void die(const char *fmt, ...); #endif /* UTIL_H */