texinfo-commits
[Top][All Lists]
Advanced

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

[5904] don't save pointers to node contents in the tag table any more


From: Gavin D. Smith
Subject: [5904] don't save pointers to node contents in the tag table any more
Date: Fri, 31 Oct 2014 17:21:06 +0000

Revision: 5904
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5904
Author:   gavin
Date:     2014-10-31 17:21:05 +0000 (Fri, 31 Oct 2014)
Log Message:
-----------
don't save pointers to node contents in the tag table any more

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/dir.c
    trunk/info/echo-area.c
    trunk/info/footnotes.c
    trunk/info/indices.c
    trunk/info/info-utils.c
    trunk/info/info-utils.h
    trunk/info/info.c
    trunk/info/infodoc.c
    trunk/info/man.c
    trunk/info/nodemenu.c
    trunk/info/nodes.c
    trunk/info/nodes.h
    trunk/info/session.c
    trunk/info/session.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/ChangeLog     2014-10-31 17:21:05 UTC (rev 5904)
@@ -1,3 +1,61 @@
+2014-10-31  Gavin Smith  <address@hidden>
+
+       * info/info-utils.c (scan_node_contents): Return a new NODE 
+       object if node was from a file, and don't set reference list of 
+       passed-in node.
+
+       * info/nodes.c (info_node_of_tag): Always call 
+       scan_node_contents.  Node data like the contents pointer or 
+       reference list is not saved in the tag table any more.
+       (set_tag_nodelen): Passed in tag points to start of node 
+       separator instead of just after it.
+
+       * info/nodes.h (N_Unstored): Symbol deleted.
+       * info/footnotes.c (make_footnotes_node),
+       * info/indices.c (info_index_apropos, info_virtual_index)
+       * info/nodemenu.c (list_visited_nodes),
+       * info/echo-area.c (ea_possible_completions): Mark generated 
+       nodes with N_WasRewritten instead of N_Unstored.
+
+       * info/nodes.h (NODE): Remove out-of-date comment.
+       * info/info-utils.c (free_history_node): No longer static.  
+       Check if argument is null.  Free node contents if N_WasRewritten 
+       flag is set.  Free 'next', 'prev' and 'up' fields.
+       * info/dir.c (dir_entry_of_infodir),
+       * info/session.c (dump_node_to_stream, info_intuit_options_node)
+       (info_search_internal),
+       * info/info.c (add_initial_nodes, info_follow_menus),
+       * info/indices.c (info_indices_of_file_buffer),
+       * info/footnotes.c (make_footnotes_node): Call free_history_node 
+       on nodes instead of calling 'free'.
+
+       * info/dir.c (build_dir_node): Call to scan_node_contents 
+       updated.
+       (get_dir_node): Copy some fields from saved dir node.
+       (lookup_dir_entry): Don't call get_dir_node.
+
+       * info/session.c (free_node_contents): Function deleted.
+       * info/session.c (add_gcable_pointer, gcable_pointers)
+       (gcable_pointers_index, gcable_pointers_slots): Removed.  All 
+       calls to add_gcable_pointer removed.
+       (gc_file_buffers_and_nodes): Don't process gcable_pointers.
+
+       * info/session.c (info_split_window): Copy some fields of node 
+       object so they can be passed to free_history_node.
+
+       * info/nodes.h (N_FromAnchor): Removed.
+       * info/info-utils.c (info_node_of_tag) <anchor>: Don't set 
+       N_FromAnchor flag.
+
+       * info/info.c (info_find_matching_files): Free return value of 
+       info_file_find_next_in_path.
+       (add_initial_nodes) <--node>: Don't duplicate a string which is 
+       lost.
+       * info/footnotes.c (make_footnotes_node): Copy terminating null 
+       byte into contents of footnote node.
+       * info/session.c (ask_for_search_string): Free returned string 
+       even if it is of length 0.
+
 2014-10-29  Gavin Smith  <address@hidden>
 
        * info/session.c (SEARCH_STATE, push_isearch, pop_isearch)

Modified: trunk/info/dir.c
===================================================================
--- trunk/info/dir.c    2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/dir.c    2014-10-31 17:21:05 UTC (rev 5904)
@@ -52,6 +52,12 @@
 
   node = xmalloc (sizeof (NODE));
   *node = *dir_node;
+
+  /* Allow the node to be passed to free_history_node. */
+  if (node->flags & N_WasRewritten)
+    node->flags &= ~N_WasRewritten;
+  node->references = info_copy_references (node->references);
+  node->nodename = xstrdup (node->nodename);
   return node;
 }
 
@@ -138,11 +144,8 @@
     }
 
   {
-    char *old_contents = node->contents;
     node->flags |= (N_IsDir | N_IsInternal);
     scan_node_contents (0, &node);
-    if (node->flags & N_WasRewritten)
-      free (old_contents);
   }
   return node;
 }
@@ -254,12 +257,13 @@
 REFERENCE *
 lookup_dir_entry (char *label, int sloppy)
 {
-  NODE *node = get_dir_node ();
   REFERENCE *entry;
 
-  entry = info_get_menu_entry_by_label (node, label, sloppy);
-  free (node);
+  if (!dir_node)
+    dir_node = build_dir_node ();
 
+  entry = info_get_menu_entry_by_label (dir_node, label, sloppy);
+
   return entry;
 }
 
@@ -287,7 +291,7 @@
       dir_node = info_get_node (dir_fullpath, "Top");
       free (dir_fullpath);
       entry = info_get_menu_entry_by_label (dir_node, label, 1);
-      free (dir_node);
+      free_history_node (dir_node);
       if (!entry)
         continue;
 

Modified: trunk/info/echo-area.c
===================================================================
--- trunk/info/echo-area.c      2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/echo-area.c      2014-10-31 17:21:05 UTC (rev 5904)
@@ -1042,9 +1042,9 @@
         NODE *temp;
 
         temp = text_buffer_to_node (&message);
-        add_gcable_pointer (temp->contents);
         name_internal_node (temp, xstrdup (compwin_name));
         possible_completions_output_node = temp;
+        possible_completions_output_node->flags |= N_WasRewritten;
       }
 
       /* Find a suitable window for displaying the completions output.

Modified: trunk/info/footnotes.c
===================================================================
--- trunk/info/footnotes.c      2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/footnotes.c      2014-10-31 17:21:05 UTC (rev 5904)
@@ -137,7 +137,7 @@
     result->contents = xmalloc (1 + result->nodelen);
     sprintf (result->contents, "%s", header);
     memcpy (result->contents + strlen (header),
-            fn_node->contents + text_start, fn_node->nodelen - text_start);
+            fn_node->contents + text_start, fn_node->nodelen - text_start + 1);
 
    /* Copy and adjust references that appear in footnotes section. */
     {
@@ -159,7 +159,7 @@
     }
 
     result->nodename = xstrdup (footnote_nodename);
-    result->flags |= (N_IsInternal | N_Unstored);
+    result->flags |= N_IsInternal | N_WasRewritten;
 
     /* Needed in case the user follows a reference in the footnotes window. */
     result->fullpath = fn_node->fullpath;
@@ -168,7 +168,7 @@
     free (header);
   }
 
-  free (footnotes_node);
+  free_history_node (footnotes_node);
   return result;
 }
 
@@ -236,7 +236,6 @@
      (info_get_or_remove_footnotes), but we do not recurse indefinitely
      because we check if we are in the footnote window above. */
   info_set_node_of_window (fn_win, new_footnotes);
-  add_gcable_pointer (new_footnotes->contents);
   fn_win->flags |= W_TempWindow;
 
   /* Make the height be the number of lines appearing in the footnotes. */

Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c        2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/indices.c        2014-10-31 17:21:05 UTC (rev 5904)
@@ -177,7 +177,10 @@
                   free (old_result);
                   }
                 }
-              free (node);
+              free (menu);
+              node->references = 0; /* Don't free the elements in the
+                                       reference list. */
+              free_history_node (node);
             }
         }
     }
@@ -683,9 +686,8 @@
       apropos_node = text_buffer_to_node (&message);
       scan_node_contents (0, &apropos_node);
 
-      add_gcable_pointer (apropos_node->contents);
       name_internal_node (apropos_node, xstrdup (apropos_list_nodename));
-      apropos_node->flags |= N_Unstored;
+      apropos_node->flags |= N_WasRewritten;
 
       /* Find/Create a window to contain this node. */
       {
@@ -840,7 +842,7 @@
   node->contents = text_buffer_base (&text);
   node->nodelen = text_buffer_off (&text) - 1;
   node->body_start = strcspn (node->contents, "\n");
-  node->flags |= (N_IsInternal | N_Unstored);
+  node->flags |= N_IsInternal | N_WasRewritten;
 
   scan_node_contents (0, &node);
   info_set_node_of_window (window, node);

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/info-utils.c     2014-10-31 17:21:05 UTC (rev 5904)
@@ -1621,16 +1621,19 @@
    cross-references and menu items.  Convert character encoding of
    node contents to that of the user if the two are known to be
    different.  If preprocess_nodes_p == 1, remove Info syntax in contents.
-   If the node is from the file described by FB, then NODE_PTR is an offset
-   into FB->tags.  If the node has not come from a file, FB is a null
-   pointer. */
-void
+
+   If FB is non-null, it is the file containing the node, and NODE_PTR is an 
+   offset into FB->tags.  Return a new node.
+  
+   If the node has not come from a file, FB is a null pointer.  Update
+   **NODE_PTR and return null. */
+NODE *
 scan_node_contents (FILE_BUFFER *fb, NODE **node_ptr)
 {
   int in_menu = 0;
   char *match;
 
-  NODE *node = *node_ptr;
+  NODE *node; /* Return value */
 
   REFERENCE **refs = NULL;
   size_t refs_index = 0, refs_slots = 0;
@@ -1638,10 +1641,8 @@
   /* Whether an index tag was seen. */
   int in_index = 0;
 
-  /* Check that contents haven't already been processed. This shouldn't
-     happen. */
-  if (node->flags & N_WasRewritten)
-    return;
+  node = xmalloc (sizeof (NODE));
+  *node = **node_ptr;
 
   rewrite_p = preprocess_nodes_p;
 
@@ -1664,7 +1665,7 @@
         {
           FILE_BUFFER *f = info_find_subfile (node->subfile);
           if (!f)
-            return; /* This shouldn't happen. */
+            return 0; /* This shouldn't happen. */
           file_contents = f->contents;
         }
       node_offset = node->nodestart
@@ -1770,6 +1771,20 @@
       if (preprocess_nodes_p)
         node->body_start = 0;
     }
+
+  if (!fb)
+    {
+      if (node->flags & N_WasRewritten)
+        free ((*node_ptr)->contents);
+      **node_ptr = *node;
+      free (node);
+      return 0;
+    }
+  else
+    {
+      (*node_ptr)->contents = 0;
+      return node;
+    }
 }
 
 

Modified: trunk/info/info-utils.h
===================================================================
--- trunk/info/info-utils.h     2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/info-utils.h     2014-10-31 17:21:05 UTC (rev 5904)
@@ -48,7 +48,7 @@
 long read_quoted_string (char *start, char *terminator, int lines,
                          char **output);
 
-void scan_node_contents (FILE_BUFFER *fb, NODE **node_ptr);
+NODE *scan_node_contents (FILE_BUFFER *fb, NODE **node_ptr);
 
 /* Get the menu entry associated with LABEL in NODE.  Return a
    pointer to the reference if found, or NULL.  If SLOPPY, accept

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/info.c   2014-10-31 17:21:05 UTC (rev 5904)
@@ -293,7 +293,7 @@
              like info --node "(emacs)Buffers". */
           info_parse_node (user_nodenames[i]);
           if (info_parsed_filename)
-            node_filename = xstrdup (info_parsed_filename);
+            node_filename = info_parsed_filename;
           else
             {
               if (!initial_file)
@@ -302,7 +302,7 @@
                             user_nodenames[i]);
                   continue;
                 }
-              node_filename = xstrdup (initial_file);
+              node_filename = initial_file;
             }
 
           add_pointer_to_array
@@ -380,7 +380,7 @@
           info_reference_free (ref_list[0]);
           ref_list[0] = info_new_reference (node_via_menus->fullpath,
                                             node_via_menus->nodename);
-          free (node_via_menus);
+          free_history_node (node_via_menus);
         }
 
       /* If no nodes found, and there is exactly one argument remaining,
@@ -421,7 +421,7 @@
               info_reference_free (ref_list[0]);
               ref_list[0] = info_new_reference (node_via_menus->fullpath,
                                                 node_via_menus->nodename);
-              free (node_via_menus);
+              free_history_node (node_via_menus);
             }
         }
     }
@@ -473,6 +473,7 @@
           add_pointer_to_array (info_new_reference (p, 0),
             ref_index, ref_list, ref_slots, 2);
         }
+      free (p);
     }
 
   /* Check for man page. */

Modified: trunk/info/infodoc.c
===================================================================
--- trunk/info/infodoc.c        2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/infodoc.c        2014-10-31 17:21:05 UTC (rev 5904)
@@ -275,15 +275,6 @@
 
   internal_info_help_node = node;
 
-  /* Do not GC this node's contents.  It never changes, and we never need
-     to delete it once it is made.  If you change some things (such as
-     placing information about dynamic variables in the help text) then
-     you will need to allow the contents to be gc'd, and you will have to
-     arrange to always regenerate the help node. */
-#if defined (HELP_NODE_GETS_REGENERATED)
-  add_gcable_pointer (internal_info_help_node->contents);
-#endif
-
   name_internal_node (internal_info_help_node, xstrdup (info_help_nodename));
 }
 

Modified: trunk/info/man.c
===================================================================
--- trunk/info/man.c    2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/man.c    2014-10-31 17:21:05 UTC (rev 5904)
@@ -126,7 +126,6 @@
           tag->nodelen = plen;
         }
 
-      /* FIXME: add_gcable_pointer (tag->contents)? */
       tag->body_start = strcspn (tag->contents, "\n");
     }
 

Modified: trunk/info/nodemenu.c
===================================================================
--- trunk/info/nodemenu.c       2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/nodemenu.c       2014-10-31 17:21:05 UTC (rev 5904)
@@ -197,8 +197,6 @@
     free (lines);
 
   node = text_buffer_to_node (&message);
-  add_gcable_pointer (node->contents);
-
   scan_node_contents (0, &node);
 
   return node;
@@ -243,7 +241,7 @@
   new->flags |= W_NoWrap;
   node = get_visited_nodes ();
   name_internal_node (node, xstrdup (nodemenu_nodename));
-  node->flags |= N_Unstored;
+  node->flags |= N_WasRewritten;
 
   info_set_node_of_window (new, node);
   active_window = new;

Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c  2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/nodes.c  2014-10-31 17:21:05 UTC (rev 5904)
@@ -1166,10 +1166,11 @@
 {
   SEARCH_BINDING node_body;
 
-  node_body.buffer = tag->contents;
-  node_body.start = 0;
-  node_body.end = subfile->contents + subfile->filesize - node_body.buffer;
+  node_body.buffer = subfile->contents;
+  node_body.start = tag->nodestart;
+  node_body.end = subfile->filesize;
   node_body.flags = 0;
+  node_body.start += skip_node_separator (node_body.buffer + node_body.start);
   tag->nodelen = get_node_length (&node_body);
 }
 
@@ -1205,33 +1206,38 @@
 
   node = 0;
 
-  /* If not an anchor and contents of node are not available: */
-  if (tag->nodelen != 0 && !tag->contents)
+  if (tag->nodelen != 0) /* If not an anchor. */
     {
       /* If TAG->nodelen hasn't been calculated yet, then we aren't
          in a position to trust the entry pointer.  Adjust things so
-         that ENTRY->nodestart gets the exact address of the start of
+         that TAG->nodestart gets the exact address of the start of
          the node separator which starts this node.  If we cannot
          do that, the node isn't really here. */
       if (tag->nodelen == -1)
-        if (!adjust_nodestart (subfile, tag))
-          return NULL; /* Node not found. */
+        {
+          if (!adjust_nodestart (subfile, tag))
+            return NULL; /* Node not found. */
 
-      /* Right after the separator. */
+          set_tag_nodelen (subfile, tag);
+        }
+
       tag->contents = subfile->contents + tag->nodestart;
       tag->contents += skip_node_separator (tag->contents);
-
-      /* This may be already calculated, but be out of date
-         due to previous calls to tags_expand. */
-      set_tag_nodelen (subfile, tag);
-
       node_set_body_start (tag);
 
-      /* Read locations of references in node and similar.  Strip
-         Info file syntax from node if preprocess_nodes=On. */
-      scan_node_contents (fb, tag_ptr);
+      /* Read locations of references in node and similar.  Strip Info file
+         syntax from node if preprocess_nodes=On.  Adjust the offsets of
+         anchors that occur within the node.*/
+      node = scan_node_contents (fb, tag_ptr);
+      node->nodename = xstrdup (node->nodename);
+
+      /* We can't set this when tag table is built, because
+         if file is split, we don't know which of the sub-files
+         are compressed. */
+      if (subfile->flags & N_IsCompressed)
+        node->flags |= N_IsCompressed;
     }
-  else if (tag->nodelen == 0) /* anchor, return containing node */
+  else /* anchor, return containing node */
     {
       int anchor_pos, node_pos;
 
@@ -1267,23 +1273,8 @@
              the screen), which looks wrong.  */
           if (node->display_pos >= (unsigned long) node->nodelen)
             node->display_pos = node->nodelen - 1;
-
-          /* Don't search in the node for the xref text, it's not there.  */
-          node->flags |= N_FromAnchor;
         }
     }
 
-  if (!node)
-    {
-      node = xmalloc (sizeof (NODE));
-      *node = *tag;
-    }
-
-  /* We can't set this when tag table is built, because
-     if file is split, we don't know which of the sub-files
-     are compressed. */
-  if (subfile->flags & N_IsCompressed)
-    node->flags |= N_IsCompressed;
-  
   return node;
 }

Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h  2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/nodes.h  2014-10-31 17:21:05 UTC (rev 5904)
@@ -39,14 +39,6 @@
 #define REFERENCE_XREF 0
 #define REFERENCE_MENU_ITEM 1
 
-/* Callers generally only want the node itself.  This structure is used
-   to pass node information around.  None of the information in this
-   structure should ever be directly freed.  The structure itself can
-   be passed to free ().  Note that NODE->parent is non-null if this
-   node's file is a subfile.  In that case, NODE->parent is the logical
-   name of the file containing this node.  Both names are given as full
-   paths, so you might have: node->filename = "/usr/gnu/info/emacs-1",
-   with node->parent = "/usr/gnu/info/emacs". */
 typedef struct {
   char *fullpath;               /* Non-null is the logical file name. */
   char *subfile;                /* File containing node for split files. */
@@ -74,12 +66,10 @@
 #define N_IsInternal   0x10     /* This node was made by Info. */
 #define N_CannotGC     0x20     /* File buffer cannot be gc'ed. */
 #define N_IsManPage    0x40     /* This node is a manpage. */
-#define N_FromAnchor   0x80     /* Synthesized for an anchor reference. */
 #define N_WasRewritten 0x100    /* NODE->contents can be passed to free(). */ 
 #define N_IsIndex      0x200    /* An index node. */
 #define N_IsDir        0x400    /* A dir node. */
 #define N_Subfile      0x800    /* File buffer is a subfile of a split file. */
-#define N_Unstored     0x1000   /* References are not stored anywhere else. */
 
 /* String constants. */
 #define INFO_FILE_LABEL                 "File:"
@@ -171,6 +161,8 @@
    various slots.  This can also be used to rebuild a tag or node table. */
 extern void build_tags_and_nodes (FILE_BUFFER *file_buffer);
 
+void free_history_node (NODE *n);
+
 /* When non-zero, this is a string describing the most recent file error. */
 extern char *info_recent_file_error;
 

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/session.c        2014-10-31 17:21:05 UTC (rev 5904)
@@ -902,17 +902,17 @@
 /*                                                                  */
 /* **************************************************************** */
 
-static void
+/* Free a NODE object that is suitable for being placed in a window. */
+void
 free_history_node (NODE *n)
 {
-  if (n->flags & N_Unstored)
-    {
-      /* These fields are not stored anywhere else.  The
-         contents field was recorded with add_gcable_pointer. */
-      info_free_references (n->references);
-      free (n->nodename);
-    }
-
+  if (!n)
+    return;
+  if (n->flags & N_WasRewritten)
+    free (n->contents);
+  info_free_references (n->references);
+  free (n->next); free (n->prev); free (n->up);
+  free (n->nodename);
   free (n);
 }
 
@@ -1692,57 +1692,17 @@
 /*                                                                  */
 /* **************************************************************** */
 
-
-/* Contents of displayed nodes with no corresponding file buffer. */
-static char **gcable_pointers = NULL;
-static size_t gcable_pointers_index = 0;
-static size_t gcable_pointers_slots = 0;
-
-/* Add POINTER to the list of garbage collectible pointers.  A pointer
-   is not garbage collected until no window contains a node whose contents
-   member is equal to the pointer. */
-void
-add_gcable_pointer (char *pointer)
-{
-  add_pointer_to_array (pointer, gcable_pointers_index, gcable_pointers,
-                       gcable_pointers_slots, 10);
-}
-
-/* Free contents of rewritten nodes in the file's tag table.  This will
-   do nothing for a subfile of a split file. */
 static void
-free_node_contents (FILE_BUFFER *fb)
-{
-  NODE **entry;
-
-  if (!fb->tags)
-    return;
-
-  for (entry = fb->tags; *entry; entry++)
-    if ((*entry)->flags & N_WasRewritten)
-      {
-        free ((*entry)->contents);
-        (*entry)->contents = 0;
-        (*entry)->flags &= ~N_WasRewritten;
-      }
-}
-
-static void
 gc_file_buffers_and_nodes (void)
 {
   /* Array to record whether each file buffer was referenced or not. */
   int *fb_referenced = xcalloc (info_loaded_files_index, sizeof (int));
   WINDOW *win;
-  int i, j;
-  int fb_index, nc_index;
+  int i;
+  int fb_index;
 
-  /* New value of gcable_pointers. */
-  char **new = NULL;
-  size_t new_index = 0;
-  size_t new_slots = 0;
-
-  /* Loop over nodes in the history of displayed windows recording which
-     nodes and file buffers were referenced. */
+  /* Loop over nodes in the history of displayed windows recording
+     which file buffers were referenced. */
   for (win = windows; win; win = win->next)
     {
       if (!win->hist)
@@ -1756,39 +1716,25 @@
             {
               FILE_BUFFER *fb = info_loaded_files[fb_index];
 
-              /* Each node should match at most one subfile and one 
-                 non-subfile. */
+              /* Each node should match at most one file, either a subfile or 
a 
+                 non-split file. */
               if (fb->flags & N_Subfile)
                 {
-                  /* FIXME: For now, never free a subfile contents.  It can be 
-                     referenced by contents pointers in the tag table for the 
-                     main file.  Either check for this case, or do not store 
-                     contents pointers. */
-                  fb_referenced[fb_index] = 1;
-                  /*
                   if (n->subfile && !FILENAME_CMP (fb->fullpath, n->subfile))
                     {
                       fb_referenced[fb_index] = 1;
+                      break;
                     }
-                  */
                 }
-              else
+              else if (!(fb->flags & N_TagsIndirect))
                 {
                   if (n->fullpath && !FILENAME_CMP (fb->fullpath, n->fullpath))
                     {
                       fb_referenced[fb_index] = 1;
+                      break;
                     }
                 }
             }
-
-          /* Loop over gcable_pointers. */
-          for (nc_index = 0; nc_index < gcable_pointers_index; nc_index++)
-            if (n->contents == gcable_pointers[nc_index])
-              {
-                add_pointer_to_array (n->contents, new_index, new, 
-                                      new_slots, 10);
-                break;
-              }
         }
     }
 
@@ -1800,10 +1746,7 @@
           FILE_BUFFER *fb = info_loaded_files[i];
 
           if (fb->flags & N_TagsIndirect)
-            {
-              free_node_contents (fb);
-              continue;
-            }
+            continue;
 
           /* If already gc-ed, do nothing. */
           if (!fb->contents)
@@ -1819,30 +1762,11 @@
           if (fb->flags & N_CannotGC)
             continue;
 
-          free_node_contents (fb);
           free (fb->contents);
           fb->contents = 0;
         }
     }
 
-  /* Free unreferenced node contents and update gcable_pointers. */
-  for (i = 0; i < gcable_pointers_index; i++)
-    {
-      for (j = 0; j < new_index; j++)
-       if (gcable_pointers[i] == new[j])
-         break;
-
-      /* If we got all the way through the new list, then the old pointer
-        can be garbage collected. */
-      if (!new || j == new_index)
-       free (gcable_pointers[i]);
-    }
-
-  free (gcable_pointers);
-  gcable_pointers = new;
-  gcable_pointers_slots = new_slots;
-  gcable_pointers_index = new_index;
-
   free (fb_referenced);
 }
 
@@ -1948,14 +1872,20 @@
       NODE *copy = xmalloc (sizeof (NODE));
       *copy = *window->node; /* Field-by-field copy of structure. */
 
-      /* This allows us to free internal nodes without checking if
-         these fields are shared by NODE objects in other windows. */
-      if (copy->flags & N_Unstored)
-        {
-          copy->references = info_copy_references (copy->references);
-          copy->nodename = xstrdup (copy->nodename);
-        }
+      /* This allows us to free nodes without checking if these fields
+         are shared by NODE objects in other windows. */
+      copy->references = info_copy_references (copy->references);
+      copy->nodename = xstrdup (copy->nodename);
 
+      if (copy->up)
+        copy->up = xstrdup (copy->up);
+      if (copy->next)
+        copy->next = xstrdup (copy->next);
+      if (copy->prev)
+        copy->prev = xstrdup (copy->prev);
+      if (copy->flags & N_WasRewritten)
+        copy->contents = xstrdup (copy->contents);
+
       info_set_node_of_window (split, copy);
       /* Make sure point still appears in the active window. */
       info_show_point (window);
@@ -2737,7 +2667,7 @@
             return initial_node;
           else
             {
-              free (initial_node);
+              free_history_node (initial_node);
               return 0;
             }
         }
@@ -2759,7 +2689,7 @@
             return initial_node;
           else
             {
-              free (initial_node);
+              free_history_node (initial_node);
               return 0;
             }
         }
@@ -2786,7 +2716,7 @@
       debug (3, ("node: %s, %s", node->fullpath, node->nodename));
       
       /* Success.  Go round the loop again.  */
-      free (initial_node);
+      free_history_node (initial_node);
       initial_node = node;
     }
 
@@ -3392,7 +3322,7 @@
       if (!entry->filename)
         entry->filename = xstrdup (node->fullpath);
 
-      free (node);
+      free_history_node (node);
 
       /* Try to find this node.  */
       node = info_get_node (entry->filename, entry->nodename);
@@ -3400,7 +3330,7 @@
         break;
     }
 
-  free (node);
+  free_history_node (node);
   return entry;  
 }
 
@@ -3673,7 +3603,7 @@
   /* If we have already dumped this node, don't dump it again. */
   if (info_namelist_add (&dumped_already, node->nodename))
     {
-      free (node);
+      free_history_node (node);
       return DUMP_SUCCESS;
     }
 
@@ -3682,7 +3612,7 @@
 
   if (write_node_to_stream (node, stream))
     {
-      free (node);
+      free_history_node (node);
       return DUMP_SYS_ERROR;
     }
 
@@ -3708,14 +3638,14 @@
                 if (dump_node_to_stream (filename, menu[i]->nodename,
                       stream, dump_subnodes) == DUMP_SYS_ERROR)
                   {
-                    free (node);
+                    free_history_node (node);
                     return DUMP_SYS_ERROR;
                   }
             }
         }
     }
 
-  free (node);
+  free_history_node (node);
   return DUMP_SUCCESS;
 }
 
@@ -4116,7 +4046,7 @@
 
 funexit:
   if (node != window->node)
-    free (node);
+    free_history_node (node);
   return -1;
 }
 
@@ -4145,7 +4075,10 @@
   free (prompt);
 
   if (!line || !*line)
-    return 0;
+    {
+      free (line);
+      return 0;
+    }
 
   if (mbslen (line) < min_search_length)
     {

Modified: trunk/info/session.h
===================================================================
--- trunk/info/session.h        2014-10-29 22:16:53 UTC (rev 5903)
+++ trunk/info/session.h        2014-10-31 17:21:05 UTC (rev 5904)
@@ -32,11 +32,6 @@
    to gc even those file buffer contents which had to be uncompressed. */
 extern int gc_compressed_files;
 
-/* Add POINTER to the list of garbage collectible pointers.  A pointer
-   is not actually garbage collected until no info window contains a node
-   whose contents member is equal to the pointer. */
-extern void add_gcable_pointer (char *pointer);
-
 /* When non-zero, tiling takes place automatically when info_split_window
    is called. */
 extern int auto_tiling_p;




reply via email to

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