summaryrefslogtreecommitdiffstats
path: root/include/xalloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/xalloc.h')
-rw-r--r--include/xalloc.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/xalloc.h b/include/xalloc.h
index 2a8c78bc0..ff5432e59 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -43,4 +43,13 @@ void *xcalloc(const size_t nelems, const size_t size)
return ret;
}
+static inline char *xstrdup(const char *str)
+{
+ char *ret = strdup(str);
+
+ if (!ret && str)
+ err(EXIT_FAILURE, "cannot duplicate string");
+ return ret;
+}
+
#endif