aboutsummaryrefslogtreecommitdiff
path: root/src/rc-misc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc-misc.h')
-rw-r--r--src/rc-misc.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/rc-misc.h b/src/rc-misc.h
index 40228b70..609447f7 100644
--- a/src/rc-misc.h
+++ b/src/rc-misc.h
@@ -41,6 +41,45 @@
/* Good defaults just incase user has none set */
#define RC_NET_FS_LIST_DEFAULT "afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
+#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
+
+static inline void *rc_xmalloc (size_t size)
+{
+ void *value = malloc (size);
+
+ if (value)
+ return (value);
+
+ ERRX;
+}
+
+static inline void *rc_xrealloc (void *ptr, size_t size)
+{
+ void *value = realloc (ptr, size);
+
+ if (value)
+ return (value);
+
+ ERRX;
+}
+
+static inline char *rc_xstrdup (const char *str)
+{
+ char *value;
+
+ if (! str)
+ return (NULL);
+
+ value = strdup (str);
+
+ if (value)
+ return (value);
+
+ ERRX;
+}
+
+#undef ERRX
+
static inline bool rc_exists (const char *pathname)
{
struct stat buf;