]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/misc.c
statd: Use the new nsm_ file.c calls in rpc.statd
[nfs-utils.git] / utils / statd / misc.c
1 /* 
2  * Copyright (C) 1995-1999 Jeffrey A. Uphoff
3  * Modified by Olaf Kirch, 1996.
4  * Modified by H.J. Lu, 1998.
5  *
6  * NSM for Linux.
7  */
8
9 #ifdef HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12
13 #include <errno.h>
14 #include <limits.h>
15 #include <string.h>
16 #include <unistd.h>
17 #include "statd.h"
18 #include "notlist.h"
19
20 /*
21  * Error-checking malloc() wrapper.
22  */
23 void *
24 xmalloc (size_t size)
25 {
26   void *ptr;
27
28   if (size == 0)
29     return ((void *)NULL);
30
31   if (!(ptr = malloc (size)))
32     xlog_err ("malloc failed");
33
34   return (ptr);
35 }
36
37
38 /* 
39  * Error-checking strdup() wrapper.
40  */
41 char *
42 xstrdup (const char *string)
43 {
44   char *result;
45
46   /* Will only fail if underlying malloc() fails (ENOMEM). */
47   if (!(result = strdup (string)))
48     xlog_err ("strdup failed");
49
50   return (result);
51 }