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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/* See LICENSE file for copyright and license details. */
#include <stdlib.h>
#include <string.h>
#include "../util.h"
void *
ecalloc(size_t nmemb, size_t size)
{
return encalloc(1, nmemb, size);
}
void *
emalloc(size_t size)
{
return enmalloc(1, size);
}
void *
erealloc(void *p, size_t size)
{
return enrealloc(1, p, size);
}
char *
estrdup(const char *s)
{
return enstrdup(1, s);
}
char *
estrndup(const char *s, size_t n)
{
return enstrndup(1, s, n);
}
void *
encalloc(int status, size_t nmemb, size_t size)
{
void *p;
p = calloc(nmemb, size);
if (!p)
enprintf(status, "calloc: out of memory\n");
return p;
}
void *
enmalloc(int status, size_t size)
{
void *p;
p = malloc(size);
if (!p)
enprintf(status, "malloc: out of memory\n");
return p;
}
void *
enrealloc(int status, void *p, size_t size)
{
p = realloc(p, size);
if (!p)
enprintf(status, "realloc: out of memory\n");
return p;
}
char *
enstrdup(int status, const char *s)
{
char *p;
p = strdup(s);
if (!p)
enprintf(status, "strdup: out of memory\n");
return p;
}
char *
enstrndup(int status, const char *s, size_t n)
{
char *p;
p = strndup(s, n);
if (!p)
enprintf(status, "strndup: out of memory\n");
return p;
}
|