From 5e4b1826168b74d8b5e71227ded12980efd5a243 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Thu, 15 Oct 2020 00:56:22 +0200 Subject: Combine XAlloc.[ch] into XUtils.[ch] --- XUtils.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'XUtils.c') diff --git a/XUtils.c b/XUtils.c index 9228c5e8..f654b4bc 100644 --- a/XUtils.c +++ b/XUtils.c @@ -14,9 +14,38 @@ in the source distribution for its full text. #include #include -#include "XAlloc.h" +#include "CRT.h" +void fail() { + CRT_done(); + abort(); +} + +void* xMalloc(size_t size) { + void* data = malloc(size); + if (!data && size > 0) { + fail(); + } + return data; +} + +void* xCalloc(size_t nmemb, size_t size) { + void* data = calloc(nmemb, size); + if (!data && nmemb > 0 && size > 0) { + fail(); + } + return data; +} + +void* xRealloc(void* ptr, size_t size) { + void* data = realloc(ptr, size); + if (!data && size > 0) { + fail(); + } + return data; +} + char* String_cat(const char* s1, const char* s2) { int l1 = strlen(s1); int l2 = strlen(s2); -- cgit v1.2.3