texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[5874] duplicate arguments to info_new_reference


From: Gavin D. Smith
Subject: [5874] duplicate arguments to info_new_reference
Date: Tue, 14 Oct 2014 16:20:00 +0000

Revision: 5874
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5874
Author:   gavin
Date:     2014-10-14 16:19:59 +0000 (Tue, 14 Oct 2014)
Log Message:
-----------
duplicate arguments to info_new_reference

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/info-utils.c
    trunk/info/info.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-10-14 16:12:31 UTC (rev 5873)
+++ trunk/ChangeLog     2014-10-14 16:19:59 UTC (rev 5874)
@@ -7,6 +7,9 @@
        should already be in ref_list.  If any "--node" argument given, 
        discard the first element of ref_list.
 
+       * info/info-utils.c (info_new_reference): Duplicate arguments 
+       into new storage.  All callers updated.
+
 2014-10-13  Gavin Smith  <address@hidden>
 
        * info/info.c (main) <--all not used>: Check if the first 

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2014-10-14 16:12:31 UTC (rev 5873)
+++ trunk/info/info-utils.c     2014-10-14 16:19:59 UTC (rev 5874)
@@ -372,15 +372,14 @@
     }
 }
 
-/* Return new REFERENCE with filename and nodename fields set.  References
-   to FILENAME and NODENAME are retained in the return value. */
+/* Return new REFERENCE with filename and nodename fields set. */
 REFERENCE *
 info_new_reference (char *filename, char *nodename)
 {
   REFERENCE *r = xmalloc (sizeof (REFERENCE));
   r->label = 0;
-  r->filename = filename;
-  r->nodename = nodename;
+  r->filename = filename ? xstrdup (filename) : 0;
+  r->nodename = nodename ? xstrdup (nodename) : 0;
   r->start = 0;
   r->end = 0;
   r->line_number = 0;

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2014-10-14 16:12:31 UTC (rev 5873)
+++ trunk/info/info.c   2014-10-14 16:19:59 UTC (rev 5874)
@@ -214,10 +214,8 @@
       initial_file = info_find_fullpath ((*argv)[0], 0);
       if (initial_file)
         {
-          add_pointer_to_array
-            (info_new_reference (xstrdup ((*argv)[0]),
-                                 xstrdup ("Top")),
-             ref_index, ref_list, ref_slots, 2);
+          add_pointer_to_array (info_new_reference ((*argv)[0], "Top"),
+                                ref_index, ref_list, ref_slots, 2);
           (*argv)++; /* Advance past first remaining argument. */
           (*argc)--;
           return;
@@ -312,8 +310,7 @@
             }
 
           add_pointer_to_array
-            (info_new_reference (node_filename,
-               info_parsed_nodename ? xstrdup (info_parsed_nodename) : 0),
+            (info_new_reference (node_filename, info_parsed_nodename),
              ref_index, ref_list, ref_slots, 2);
         }
     }
@@ -376,8 +373,7 @@
 
       if (ref_index == 0 && initial_file)
         add_pointer_to_array
-          (info_new_reference (xstrdup (initial_file->fullpath),
-                               xstrdup ("Top")),
+          (info_new_reference (initial_file->fullpath, "Top"),
            ref_index, ref_list, ref_slots, 2);
 
       /* This shouldn't happen. */
@@ -825,10 +821,8 @@
           if (!initial_file && filesys_error_number)
             error = filesys_error_string (user_filename, filesys_error_number);
           else
-            add_pointer_to_array
-              (info_new_reference (xstrdup (initial_file),
-                                   xstrdup ("Top")),
-               ref_index, ref_list, ref_slots, 2);
+            add_pointer_to_array (info_new_reference (initial_file, "Top"),
+                                  ref_index, ref_list, ref_slots, 2);
           goto skip_get_initial_file;
         }
 
@@ -842,12 +836,9 @@
           info_parse_node (argv[0]);
           if (info_parsed_filename)
             {
-              add_pointer_to_array
-                (info_new_reference (xstrdup (info_parsed_filename),
-                                     info_parsed_nodename
-                                       ? xstrdup (info_parsed_nodename)
-                                       : 0),
-                 ref_index, ref_list, ref_slots, 2);
+              add_pointer_to_array (info_new_reference (info_parsed_filename,
+                                                        info_parsed_nodename),
+                                    ref_index, ref_list, ref_slots, 2);
               memmove (argv, argv + 1, argc-- * sizeof (char *));
               goto skip_get_initial_file;
             }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]