Combine XAlloc.[ch] into XUtils.[ch]

This commit is contained in:
Benny Baumann
2020-10-15 00:56:22 +02:00
parent 872e542f4e
commit 5e4b182616
10 changed files with 46 additions and 72 deletions

View File

@ -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);