Change regcache list to be an hash map
[deliverable/binutils-gdb.git] / libiberty / argv.c
index c6a79d215e308a7e971ec3c073e2c8f74c8cfbbe..6444896f995a8e4abfb6a1edc510f3a4bbe1a30b 100644 (file)
@@ -1,5 +1,5 @@
 /* Create and destroy argument vectors (argv's)
-   Copyright (C) 1992-2018 Free Software Foundation, Inc.
+   Copyright (C) 1992-2019 Free Software Foundation, Inc.
    Written by Fred Fish @ Cygnus Support
 
 This file is part of the libiberty library.
@@ -367,8 +367,8 @@ expandargv (int *argcp, char ***argvp)
 {
   /* The argument we are currently processing.  */
   int i = 0;
-  /* Non-zero if ***argvp has been dynamically allocated.  */
-  int argv_dynamic = 0;
+  /* To check if ***argvp has been dynamically allocated.  */
+  char ** const original_argv = *argvp;
   /* Limit the number of response files that we parse in order
      to prevent infinite recursion.  */
   unsigned int iteration_limit = 2000;
@@ -449,12 +449,14 @@ expandargv (int *argcp, char ***argvp)
        /* Parse the string.  */
        file_argv = buildargv (buffer);
       /* If *ARGVP is not already dynamically allocated, copy it.  */
-      if (!argv_dynamic)
+      if (*argvp == original_argv)
        *argvp = dupargv (*argvp);
       /* Count the number of arguments.  */
       file_argc = 0;
       while (file_argv[file_argc])
        ++file_argc;
+      /* Free the original option's memory.  */
+      free ((*argvp)[i]);
       /* Now, insert FILE_ARGV into ARGV.  The "+1" below handles the
         NULL terminator at the end of ARGV.  */ 
       *argvp = ((char **) 
This page took 0.02396 seconds and 4 git commands to generate.