summaryrefslogtreecommitdiffstats
path: root/include/xalloc.h
diff options
context:
space:
mode:
authorKarel Zak2010-11-24 16:39:15 +0100
committerKarel Zak2010-11-24 17:08:32 +0100
commitecc264bc39537486109c7bb80c937b5931326200 (patch)
treee4b0f14bb0cf6d3b6e65b53b177b53d5ca5bfaf3 /include/xalloc.h
parentfindmnt: apply new changes from tt.c (diff)
downloadkernel-qcow2-util-linux-ecc264bc39537486109c7bb80c937b5931326200.tar.gz
kernel-qcow2-util-linux-ecc264bc39537486109c7bb80c937b5931326200.tar.xz
kernel-qcow2-util-linux-ecc264bc39537486109c7bb80c937b5931326200.zip
lib: [xalloc] add xstrdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
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