blob: 01766be9c86bce363f94055397c06ecd0f8f374c (
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
37
38
39
40
41
42
43
44
45
|
/* $OpenBSD: xmalloc.c,v 1.2 2016/10/16 20:26:56 natano Exp $ */
#include <err.h>
#include <stdlib.h>
#include <string.h>
void *
emalloc(size_t size)
{
void *v;
if ((v = malloc(size)) == NULL)
err(1, "malloc");
return v;
}
void *
ecalloc(size_t nmemb, size_t size)
{
void *v;
if ((v = calloc(nmemb, size)) == NULL)
err(1, "calloc");
return v;
}
void *
erealloc(void *ptr, size_t size)
{
void *v;
if ((v = realloc(ptr, size)) == NULL)
err(1, "realloc");
return v;
}
char *
estrdup(const char *s)
{
char *s2;
if ((s2 = strdup(s)) == NULL)
err(1, "strdup");
return s2;
}
|