From 03c5fce0220d3e5d02d320f925a3b9401a397729 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Thu, 26 Dec 2024 21:42:53 -0600 Subject: Put some notes down --- src/shared.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/shared.c (limited to 'src/shared.c') diff --git a/src/shared.c b/src/shared.c new file mode 100644 index 0000000..5e58de0 --- /dev/null +++ b/src/shared.c @@ -0,0 +1,20 @@ +#include "shared.h" + +#include +#include +#include + +void* xcalloc(size_t nmemb, size_t size) { + void *mem = calloc(nmemb, size); + + if(mem == NULL) { + #if defined ___VXGG___XCALLOC_EXIT_ON_ERROR___ && ___VXGG___XCALLOC_EXIT_ON_ERROR___ > 0 + error(1, errno, " Could not allocate memory"); + #endif + + abort(); + } + + + return mem; +} \ No newline at end of file -- cgit v1.2.3