blob: d8392c192daf86376e9f8e6a0ad400ddffac5378 (
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 <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "xlib.h"
void *xmalloc(size_t size)
{
void *p = malloc(size);
if (p == NULL)
err(EXIT_FAILURE, "malloc");
return p;
}
void *xrealloc(void *ptr, size_t size)
{
void *p = realloc(ptr, size);
if (p == NULL)
err(EXIT_FAILURE, "realloc");
return p;
}
char *xstrdup(const char *str)
{
char *s = strdup(str);
if (s == NULL)
err(EXIT_FAILURE, "strdup");
return s;
}
|