]> err.no Git - util-linux/commitdiff
lib: [xalloc] add xstrdup()
authorKarel Zak <kzak@redhat.com>
Wed, 24 Nov 2010 15:39:15 +0000 (16:39 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Nov 2010 16:08:32 +0000 (17:08 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/xalloc.h
misc-utils/wipefs.c

index 2a8c78bc011b77a66b5ea5d46aad416026c2edb3..ff5432e59c47aa64b7870729becfa9215d9badc7 100644 (file)
@@ -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
index 2f223f0c23ddbd5e31a7b450bce2b8352e38b6b6..d3033446f615ff6488e19360a8a07fd6d1f23cbf 100644 (file)
@@ -136,15 +136,6 @@ add_offset(struct wipe_desc *wp0, loff_t offset, int zap)
        return wp;
 }
 
-static inline char *
-xstrdup(const char *s)
-{
-       char *x = strdup(s);
-       if (!x)
-               err(EXIT_FAILURE, _("strdup failed"));
-       return x;
-}
-
 static struct wipe_desc *
 get_offset_from_probe(struct wipe_desc *wp, blkid_probe pr, int zap)
 {