summaryrefslogtreecommitdiffstats
path: root/XUtils.c
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-10-15 00:56:22 +0200
committerBenny Baumann <BenBE@geshi.org>2020-10-17 20:54:14 +0200
commit5e4b1826168b74d8b5e71227ded12980efd5a243 (patch)
treed1b5ce276eb0ba146abaabb8ae1ddda793d230c0 /XUtils.c
parent872e542f4eca52ce2198ba3fc30a51bc5d672dae (diff)
Combine XAlloc.[ch] into XUtils.[ch]
Diffstat (limited to 'XUtils.c')
-rw-r--r--XUtils.c31
1 files changed, 30 insertions, 1 deletions
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 <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);

© 2014-2024 Faster IT GmbH | imprint | privacy policy