This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] libiberty: dupargv: rewrite to use xstrdup


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=203217665139943a4f0d1797b9a5f913b3acf184

commit 203217665139943a4f0d1797b9a5f913b3acf184
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sun Jan 3 01:29:03 2016 -0500

    libiberty: dupargv: rewrite to use xstrdup
    
    This func is basically open coding the xstrdup function, so gut it
    and use it directly.

Diff:
---
 libiberty/ChangeLog | 4 ++++
 libiberty/argv.c    | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index aa598f2..ba1e0a5 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -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
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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]