From 5e910c7e41d18dab95e34ceb6e620a8958197ae6 Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 16 Oct 2023 23:46:15 +0300 Subject: things done --- src/common.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/common.c (limited to 'src/common.c') diff --git a/src/common.c b/src/common.c new file mode 100644 index 0000000..084c584 --- /dev/null +++ b/src/common.c @@ -0,0 +1,33 @@ +#include +#include +#include "common.h" + +void *xmalloc(size_t size) +{ + void *ret; + if(!(ret = malloc(size))) { + die("malloc: %s", strerror(errno)); + } + + return ret; +} + +void *xcalloc(size_t nmemb, size_t size) +{ + void *ret; + if(!(ret = calloc(nmemb, size))) { + die("calloc: %s", strerror(errno)); + } + + return ret; +} + +void *xrealloc(void *ptr, size_t size) +{ + void *ret; + if(!(ret = realloc(ptr, size))) { + die("realloc: %s", strerror(errno)); + } + + return ret; +} -- cgit v1.2.3