blob: e4dc6b83d88927179b8fa8e040f8f95437402be5 (
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
|
#include "xalloc.h"
#include <err.h>
#include <stdlib.h>
void *xmalloc(size_t size)
{
void *res = malloc(size);
if (!res)
err(EXIT_FAILURE, "Impossible to malloc");
return res;
}
void *xcalloc(size_t nmemb, size_t size)
{
void *res = calloc(nmemb, size);
if (!res)
err(EXIT_FAILURE, "Impossible to calloc");
return res;
}
void *xrealloc(void *ptr, size_t size)
{
void *res = realloc(ptr, size);
if (!res)
err(EXIT_FAILURE, "Impossible to realloc");
return res;
}
|