diff options
author | Benny Baumann <BenBE@geshi.org> | 2020-10-15 00:56:22 +0200 |
---|---|---|
committer | Benny Baumann <BenBE@geshi.org> | 2020-10-17 20:54:14 +0200 |
commit | 5e4b1826168b74d8b5e71227ded12980efd5a243 (patch) | |
tree | d1b5ce276eb0ba146abaabb8ae1ddda793d230c0 /XUtils.c | |
parent | 872e542f4eca52ce2198ba3fc30a51bc5d672dae (diff) |
Combine XAlloc.[ch] into XUtils.[ch]
Diffstat (limited to 'XUtils.c')
-rw-r--r-- | XUtils.c | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -14,9 +14,38 @@ in the source distribution for its full text. #include <string.h> #include <strings.h> -#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); |