diff mbox

libiberty: dupargv: rewrite to use xstrdup

Message ID 1451802970-18103-1-git-send-email-vapier@gentoo.org
State New
Headers show

Commit Message

Mike Frysinger Jan. 3, 2016, 6:36 a.m. UTC
This func is basically open coding the xstrdup function, so gut it
and use it directly.

2016-01-03  Mike Frysinger  <vapier@gentoo.org>

	* argv.c (dupargv): Replace strlen/xmalloc/strcpy with xstrdup.
---
 libiberty/argv.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Ian Lance Taylor Jan. 5, 2016, 3:30 p.m. UTC | #1
On Sat, Jan 2, 2016 at 10:36 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> This func is basically open coding the xstrdup function, so gut it
> and use it directly.
>
> 2016-01-03  Mike Frysinger  <vapier@gentoo.org>
>
>         * argv.c (dupargv): Replace strlen/xmalloc/strcpy with xstrdup.

This is OK.  Thanks.

Ian
diff mbox

Patch

diff --git a/libiberty/argv.c b/libiberty/argv.c
index f2727e8..5c3dd70 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -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;
 }