libiberty: dupargv: rewrite to use xstrdup
authorMike Frysinger <vapier@gentoo.org>
Sun, 3 Jan 2016 06:29:03 +0000 (01:29 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 5 Jan 2016 20:02:57 +0000 (15:02 -0500)
This func is basically open coding the xstrdup function, so gut it
and use it directly.

libiberty/ChangeLog
libiberty/argv.c

index aa598f2..ba1e0a5 100644 (file)
@@ -1,3 +1,7 @@
+2016-01-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * argv.c (dupargv): Replace strlen/xmalloc/strcpy with xstrdup.
+
 2015-12-28  Patrick Palka  <ppalka@gcc.gnu.org>
 
        * crc32.c: In the documentation, don't refer to GDB's
index f2727e8..5c3dd70 100644 (file)
@@ -76,11 +76,7 @@ dupargv (char **argv)
 
   /* the strings */
   for (argc = 0; argv[argc] != NULL; argc++)
-    {
-      int len = strlen (argv[argc]);
-      copy[argc] = (char *) xmalloc (len + 1);
-      strcpy (copy[argc], argv[argc]);
-    }
+    copy[argc] = xstrdup (argv[argc]);
   copy[argc] = NULL;
   return copy;
 }