diff options
author | Karel Zak | 2010-11-24 16:39:15 +0100 |
---|---|---|
committer | Karel Zak | 2010-11-24 17:08:32 +0100 |
commit | ecc264bc39537486109c7bb80c937b5931326200 (patch) | |
tree | e4b0f14bb0cf6d3b6e65b53b177b53d5ca5bfaf3 /include | |
parent | findmnt: apply new changes from tt.c (diff) | |
download | kernel-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')
-rw-r--r-- | include/xalloc.h | 9 |
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 |