blob: 2beaeb8aa08e7c247198f70be04d5f4e26732841 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "shared.h"
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
#include <error.h>
#include <stdio.h>
void* xcalloc(size_t nmemb, size_t size) {
void *mem = calloc(nmemb, size);
if(mem == NULL) {
#if defined ___VXGG___XCALLOC_EXIT_ON_ERROR___ && ___VXGG___XCALLOC_EXIT_ON_ERROR___ > 0
error(1, errno, "<xcalloc> Could not allocate memory");
#endif
abort();
}
return mem;
}
void* xreallocarray(void *ptr, size_t nmemb, size_t size) {
void *mem = reallocarray(ptr, nmemb, size);
if(mem == NULL) {
#if defined ___VXGG___XCALLOC_EXIT_ON_ERROR___ && ___VXGG___XCALLOC_EXIT_ON_ERROR___ > 0
error(1, errno, "<xreallocarray> Could not allocate memory");
#endif
abort();
}
return mem;
}
|