diff options
Diffstat (limited to 'include/xalloc.h')
-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 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 |