]> git.decadent.org.uk Git - nfs-utils.git/blob - support/nfs/xmalloc.c
Define and use get_reliable_hostbyname
[nfs-utils.git] / support / nfs / xmalloc.c
1 /*
2  * support/nfs/xmalloc.c
3  *
4  * malloc with NULL checking.
5  *
6  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7  */
8
9 #include "config.h"
10
11 #include <stdlib.h>
12 #include <string.h>
13 #include "xmalloc.h"
14 #include "xlog.h"
15
16 void *
17 xmalloc(size_t size)
18 {
19         void    *ptr;
20
21         if (!(ptr = malloc(size)))
22                 xlog(L_FATAL, "malloc: out of memory");
23         return ptr;
24 }
25
26 void *
27 xrealloc(void *ptr, size_t size)
28 {
29         if (!(ptr = realloc(ptr, size)))
30                 xlog(L_FATAL, "realloc: out of memory");
31         return ptr;
32 }
33
34 void
35 xfree(void *ptr)
36 {
37         free(ptr);
38 }
39
40 char *
41 xstrdup(const char *str)
42 {
43         char    *ret;
44
45         if (!(ret = strdup(str)))
46                 xlog(L_FATAL, "strdup: out of memory");
47         return ret;
48 }