blob: 6cc942562bb5b3257ebbd237d32868af8aaeda80 (
plain) (
blame)
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
|
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
void *
must_malloc(size_t size)
{
void *ret = malloc(size);
if (ret == NULL) {
fprintf(stderr, "Out of memory\n");
exit(EXIT_ABNORMAL);
}
}
void *
must_calloc(size_t nmemb, size_t size)
{
void *ret = calloc(nmemb, size);
if (ret == NULL) {
fprintf(stderr, "Out of memory\n");
exit(EXIT_ABNORMAL);
}
return ret;
}
void *
must_realloc(void *ptr, size_t size)
{
void *ret = realloc(ptr, size);
if (ret == NULL) {
fprintf(stderr, "Out of memory\n");
exit(EXIT_ABNORMAL);
}
return ret;
}
|