summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-11-24 16:39:15 +0100
committerKarel Zak <kzak@redhat.com>2010-11-24 17:08:32 +0100
commitecc264bc39537486109c7bb80c937b5931326200 (patch)
treee4b0f14bb0cf6d3b6e65b53b177b53d5ca5bfaf3 /include
parent9ead000613ea527f047597d2978ca605f1314418 (diff)
downloadutil-linux-old-ecc264bc39537486109c7bb80c937b5931326200.tar.gz
lib: [xalloc] add xstrdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/xalloc.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/xalloc.h b/include/xalloc.h
index 2a8c78bc..ff5432e5 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