mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-14 13:04:35 +03:00
Combine XAlloc.[ch] into XUtils.[ch]
This commit is contained in:
31
XUtils.c
31
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);
|
||||
|
Reference in New Issue
Block a user