aboutsummaryrefslogtreecommitdiffstats
path: root/xlib.c
blob: 0bc81237a7bf623b345ed7bb224dfa951d448484 (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

#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>

#include <err.h>
#include <netdb.h>
#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;
}