texinfo-commits
[Top][All Lists]
Advanced

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

[5334] Changes in memory allocation routines


From: Sergey Poznyakoff
Subject: [5334] Changes in memory allocation routines
Date: Tue, 20 Aug 2013 19:15:07 +0000

Revision: 5334
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5334
Author:   gray
Date:     2013-08-20 19:15:05 +0000 (Tue, 20 Aug 2013)
Log Message:
-----------
Changes in memory allocation routines

* info/info.h (add_pointer_to_array): Use x2nrealloc.
Remove sixth argument.  All uses updated.
(maybe_free): Remove.  Use free() instead.  All uses
updated.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/echo-area.c
    trunk/info/gc.c
    trunk/info/indices.c
    trunk/info/info-utils.c
    trunk/info/info.c
    trunk/info/info.h
    trunk/info/infodoc.c
    trunk/info/m-x.c
    trunk/info/makedoc.c
    trunk/info/man.c
    trunk/info/nodemenu.c
    trunk/info/nodes.c
    trunk/info/nodes.h
    trunk/info/session.c
    trunk/info/variables.c
    trunk/info/window.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/ChangeLog     2013-08-20 19:15:05 UTC (rev 5334)
@@ -1,3 +1,10 @@
+2013-08-20  Sergey Poznyakoff  <address@hidden>
+
+       * info/info.h (add_pointer_to_array): Use x2nrealloc.
+       Remove sixth argument.  All uses updated.
+       (maybe_free): Remove.  Use free() instead.  All uses
+       updated.
+
 2013-08-20  Karl Berry  <address@hidden>
 
        * doc/texinfo.tex (\sectionheading): must do

Modified: trunk/info/echo-area.c
===================================================================
--- trunk/info/echo-area.c      2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/echo-area.c      2013-08-20 19:15:05 UTC (rev 5334)
@@ -771,8 +771,8 @@
    the variable echo_area_completion_items.  If there is only one element,
    it is the only possible completion. */
 static REFERENCE **completions_found = NULL;
-static int completions_found_index = 0;
-static int completions_found_slots = 0;
+static size_t completions_found_index = 0;
+static size_t completions_found_slots = 0;
 
 /* The lowest common denominator found while completing. */
 static REFERENCE *LCD_completion;
@@ -841,8 +841,8 @@
          a default or aborted, and if FORCE is active. */
       if (force && line && *line && completions)
         {
-          register int i;
-
+          size_t i;
+         
           build_completions ();
 
           /* If there is only one completion, then make the line be that
@@ -934,8 +934,8 @@
     }
   else
     {
-      register int i, l;
-      int limit, iterations, max_label = 0;
+      size_t i, l;
+      size_t limit, iterations, max_label = 0;
 
       initialize_message_buffer ();
       printf_to_message_buffer (ngettext ("%d completion:\n",
@@ -1112,7 +1112,8 @@
          If there are some, insert the space character and continue. */
       if (key == SPC && completions_found_index > 1)
         {
-          register int i, offset;
+          size_t i;
+         int offset;
 
           offset = input_line_end - input_line_beg;
 
@@ -1167,7 +1168,7 @@
 static void
 completions_must_be_rebuilt (void)
 {
-  maybe_free (last_completion_request);
+  free (last_completion_request);
   last_completion_request = NULL;
   last_completion_items = NULL;
 }
@@ -1177,7 +1178,8 @@
 static void
 build_completions (void)
 {
-  register int i, len;
+  size_t i;
+  int len;
   register REFERENCE *entry;
   char *request;
   int informed_of_lengthy_job = 0;
@@ -1205,7 +1207,7 @@
       return;
     }
 
-  maybe_free (last_completion_request);
+  free (last_completion_request);
   last_completion_request = request;
   last_completion_items = echo_area_completion_items;
 
@@ -1218,7 +1220,7 @@
       if (mbsncasecmp (request, entry->label, len) == 0)
         add_pointer_to_array (entry, completions_found_index,
                               completions_found, completions_found_slots,
-                              20, REFERENCE *);
+                              20);
 
       if (!informed_of_lengthy_job && completions_found_index > 100)
         {
@@ -1260,7 +1262,7 @@
           shortest = j;
       }
 
-    maybe_free (LCD_reference.label);
+    free (LCD_reference.label);
     LCD_reference.label = xmalloc (1 + shortest);
     /* Since both the sorting done inside remove_completion_duplicates
        and all the comparisons above are case-insensitive, it's
@@ -1304,7 +1306,7 @@
 static void
 remove_completion_duplicates (void)
 {
-  register int i, j;
+  size_t i, j;
   REFERENCE **temp;
   int newlen;
 
@@ -1394,8 +1396,8 @@
 } PUSHED_EA;
 
 static PUSHED_EA **pushed_echo_areas = NULL;
-static int pushed_echo_areas_index = 0;
-static int pushed_echo_areas_slots = 0;
+static size_t pushed_echo_areas_index = 0;
+static size_t pushed_echo_areas_slots = 0;
 
 /* Pushing the echo_area has a side effect of zeroing the completion_items. */
 static void
@@ -1415,7 +1417,7 @@
   pushed->compwin = echo_area_completions_window;
 
   add_pointer_to_array (pushed, pushed_echo_areas_index, pushed_echo_areas,
-                        pushed_echo_areas_slots, 4, PUSHED_EA *);
+                        pushed_echo_areas_slots, 4);
 
   echo_area_completion_items = NULL;
 }
@@ -1461,7 +1463,7 @@
 static int
 echo_area_stack_contains_completions_p (void)
 {
-  register int i;
+  size_t i;
 
   for (i = 0; i < pushed_echo_areas_index; i++)
     if (pushed_echo_areas[i]->compwin)

Modified: trunk/info/gc.c
===================================================================
--- trunk/info/gc.c     2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/gc.c     2013-08-20 19:15:05 UTC (rev 5334)
@@ -24,8 +24,8 @@
    list can be garbage collected when no info window contains a node whose
    contents member match the pointer. */
 static char **gcable_pointers = NULL;
-static int gcable_pointers_index = 0;
-static int gcable_pointers_slots = 0;
+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 actually garbage collected until no info window contains a node
@@ -35,7 +35,7 @@
 {
   gc_pointers ();
   add_pointer_to_array (pointer, gcable_pointers_index, gcable_pointers,
-                       gcable_pointers_slots, 10, char *);
+                       gcable_pointers_slots, 10);
 }
 
 /* Grovel the list of info windows and gc-able pointers finding those
@@ -43,11 +43,11 @@
 void
 gc_pointers (void)
 {
-  register int i, j, k;
+  size_t i, j, k;
   INFO_WINDOW *iw;
   char **new = NULL;
-  int new_index = 0;
-  int new_slots = 0;
+  size_t new_index = 0;
+  size_t new_slots = 0;
 
   if (!info_windows || !gcable_pointers_index)
     return;
@@ -63,8 +63,8 @@
          for (k = 0; k < gcable_pointers_index; k++)
            if (gcable_pointers[k] == node->contents)
              {
-               add_pointer_to_array
-                 (node->contents, new_index, new, new_slots, 10, char *);
+               add_pointer_to_array (node->contents, new_index, new, 
+                                      new_slots, 10);
                break;
              }
        }

Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c        2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/indices.c        2013-08-20 19:15:05 UTC (rev 5334)
@@ -51,8 +51,8 @@
 
 /* An array associating index nodenames with index offset ranges. */
 static INDEX_NAME_ASSOC **index_nodenames = NULL;
-static int index_nodenames_index = 0;
-static int index_nodenames_slots = 0;
+static size_t index_nodenames_index = 0;
+static size_t index_nodenames_slots = 0;
 
 /* Add the name of NODE, and the range of the associated index elements
    (passed in ARRAY) to index_nodenames. */
@@ -77,9 +77,8 @@
       assoc->first = 1 + index_nodenames[i]->last;
       assoc->last = assoc->first + last;
     }
-  add_pointer_to_array
-    (assoc, index_nodenames_index, index_nodenames, index_nodenames_slots,
-     10, INDEX_NAME_ASSOC *);
+  add_pointer_to_array (assoc, index_nodenames_index, index_nodenames, 
+                        index_nodenames_slots, 10);
 }
 
 /* Find and return the indices of WINDOW's file.  The indices are defined
@@ -108,8 +107,8 @@
     return NULL;
 
   /* Reset globals describing where the index was found. */
-  maybe_free (initial_index_filename);
-  maybe_free (initial_index_nodename);
+  free (initial_index_filename);
+  free (initial_index_nodename);
   initial_index_filename = NULL;
   initial_index_nodename = NULL;
 
@@ -189,7 +188,7 @@
   index_offset = 0;
 
   /* The user is selecting a new search string, so flush the old one. */
-  maybe_free (index_search);
+  free (index_search);
   index_search = NULL;
 
   /* If this window's file is not the same as the one that we last built an
@@ -536,7 +535,7 @@
 REFERENCE **
 apropos_in_all_indices (char *search_string, int inform)
 {
-  register int i, dir_index;
+  size_t i, dir_index;
   REFERENCE **all_indices = NULL;
   REFERENCE **dir_menu = NULL;
   NODE *dir_node;
@@ -636,16 +635,15 @@
   if (all_indices)
     {
       REFERENCE *entry, **apropos_list = NULL;
-      int apropos_list_index = 0;
-      int apropos_list_slots = 0;
+      size_t apropos_list_index = 0;
+      size_t apropos_list_slots = 0;
 
       for (i = 0; (entry = all_indices[i]); i++)
         {
           if (string_in_line (search_string, entry->label) != -1)
             {
-              add_pointer_to_array
-                (entry, apropos_list_index, apropos_list, apropos_list_slots,
-                 100, REFERENCE *);
+              add_pointer_to_array (entry, apropos_list_index, apropos_list, 
+                                    apropos_list_slots, 100);
             }
           else
             info_reference_free (entry);
@@ -874,7 +872,7 @@
   FILE_BUFFER *fb, *tfb;
   NODE *node;
   struct text_buffer text;
-  int i;
+  size_t i;
   size_t cnt, off;
   
   fb = file_buffer_of_window (window);

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/info-utils.c     2013-08-20 19:15:05 UTC (rev 5334)
@@ -272,7 +272,7 @@
 {
   SEARCH_BINDING tmp_search;
   REFERENCE **refs = NULL;
-  int refs_index = 0, refs_slots = 0;
+  size_t refs_index = 0, refs_slots = 0;
   int searching_for_menu_items = 0;
   long position;
 
@@ -354,8 +354,7 @@
           entry->line_number = info_parsed_line_number;
         }
 
-      add_pointer_to_array
-        (entry, refs_index, refs, refs_slots, 50, REFERENCE *);
+      add_pointer_to_array (entry, refs_index, refs, refs_slots, 50);
     }
   return refs;
 }
@@ -440,9 +439,9 @@
 {
   if (ref)
     {
-      maybe_free (ref->label);
-      maybe_free (ref->filename);
-      maybe_free (ref->nodename);
+      free (ref->label);
+      free (ref->filename);
+      free (ref->nodename);
       free (ref);
     }
 }

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/info.c   2013-08-20 19:15:05 UTC (rev 5334)
@@ -58,8 +58,8 @@
 /* Array of the names of nodes that the user specified with "--node" on the
    command line. */
 static char **user_nodenames = NULL;
-static int user_nodenames_index = 0;
-static int user_nodenames_slots = 0;
+static size_t user_nodenames_index = 0;
+static size_t user_nodenames_slots = 0;
 
 /* String specifying the first file to load.  This string can only be set
    by the user specifying "--file" on the command line. */
@@ -525,8 +525,8 @@
     {
       int option_character;
 
-      option_character = getopt_long
-        (argc, argv, short_options, long_options, &getopt_long_index);
+      option_character = getopt_long (argc, argv, short_options, long_options,
+                                     &getopt_long_index);
 
       /* getopt_long returns EOF when there are no more long options. */
       if (option_character == EOF)
@@ -554,7 +554,7 @@
           /* User is specifying a particular node. */
         case 'n':
           add_pointer_to_array (optarg, user_nodenames_index, user_nodenames,
-                                user_nodenames_slots, 10, char *);
+                                user_nodenames_slots, 10);
           break;
 
           /* User is specifying a particular Info file. */
@@ -610,7 +610,7 @@
           /* User has specified a string to search all indices for. */
         case 'k':
           apropos_p = 1;
-          maybe_free (apropos_search_string);
+          free (apropos_search_string);
           apropos_search_string = xstrdup (optarg);
           break;
 
@@ -628,7 +628,7 @@
           /* User has specified a string to search all indices for. */
         case IDXSRCH_OPTION:
           index_search_p = 1;
-          maybe_free (index_search_string);
+          free (index_search_string);
           index_search_string = xstrdup (optarg);
           break;
 

Modified: trunk/info/info.h
===================================================================
--- trunk/info/info.h   2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/info.h   2013-08-20 19:15:05 UTC (rev 5334)
@@ -63,16 +63,20 @@
    array where POINTER should be added.  GROW is the number of slots to grow
    ARRAY by, in the case that it needs growing.  TYPE is a cast of the type
    of object stored in ARRAY (e.g., NODE_ENTRY *. */
-#define add_pointer_to_array(pointer, idx, array, slots, grow, type) \
-  do { \
-    if (idx + 2 >= slots) \
-      array = (type *)(xrealloc (array, (slots += grow) * sizeof (type))); \
-    array[idx++] = (type)pointer; \
-    array[idx] = (type)NULL; \
-  } while (0)
+#define add_pointer_to_array(pointer, idx, array, slots, minslots)     \
+  do                                                                   \
+    {                                                                  \
+       if (idx + 2 >= slots)                                           \
+        {                                                              \
+          if (slots == 0)                                              \
+            slots = minslots;                                          \
+          array = x2nrealloc (array, &slots, sizeof(array[0]));        \
+        }                                                              \
+       array[idx++] = pointer;                                         \
+       array[idx] = NULL;                                              \
+    }                                                                  \
+  while (0)
 
-#define maybe_free(x) do { if (x) free (x); } while (0)
-
 #if !defined (zero_mem) && defined (HAVE_MEMSET)
 #  define zero_mem(mem, length) memset (mem, 0, length)
 #endif /* !zero_mem && HAVE_MEMSET */

Modified: trunk/info/infodoc.c
===================================================================
--- trunk/info/infodoc.c        2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/infodoc.c        2013-08-20 19:15:05 UTC (rev 5334)
@@ -358,7 +358,7 @@
       if (printed_one_mx)
         printf_to_message_buffer ("\n");
 
-      maybe_free (exec_keys);
+      free (exec_keys);
 #endif /* NAMED_FUNCTIONS */
 
       node = message_buffer_to_node ();
@@ -863,7 +863,7 @@
   register int i, start, next;
   static char *result = NULL;
 
-  maybe_free (result);
+  free (result);
   result = xmalloc (1 + reslen);
 
   i = next = start = 0;
@@ -1014,7 +1014,7 @@
                 start++;
             }
 
-          maybe_free (fmt);
+          free (fmt);
         }
     }
   strcpy (result + next, string + start);

Modified: trunk/info/m-x.c
===================================================================
--- trunk/info/m-x.c    2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/m-x.c    2013-08-20 19:15:05 UTC (rev 5334)
@@ -37,7 +37,7 @@
   register int i;
   char *line;
   REFERENCE **array = NULL;
-  int array_index = 0, array_slots = 0;
+  size_t array_index = 0, array_slots = 0;
 
   /* Make an array of REFERENCE which actually contains the names of
      the functions available in Info. */
@@ -50,8 +50,7 @@
       entry->nodename = NULL;
       entry->filename = NULL;
 
-      add_pointer_to_array
-        (entry, array_index, array, array_slots, 200, REFERENCE *);
+      add_pointer_to_array (entry, array_index, array, array_slots, 200);
     }
 
   line = info_read_completing_in_echo_area (window, prompt, array);

Modified: trunk/info/makedoc.c
===================================================================
--- trunk/info/makedoc.c        2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/makedoc.c        2013-08-20 19:15:05 UTC (rev 5334)
@@ -96,13 +96,13 @@
   char *filename;               /* Name of the file containing entries. */
   long entrylen;                /* Total number of characters in tag block. */
   EMACS_TAG **entries;          /* Entries found in FILENAME. */
-  int entries_index;
-  int entries_slots;
+  size_t entries_index;
+  size_t entries_slots;
 } EMACS_TAG_BLOCK;
 
 EMACS_TAG_BLOCK **emacs_tags = NULL;
-int emacs_tags_index = 0;
-int emacs_tags_slots = 0;
+size_t emacs_tags_index = 0;
+size_t emacs_tags_slots = 0;
 
 #define DECLARATION_STRING "\nDECLARE_INFO_COMMAND"
 
@@ -243,7 +243,7 @@
 static void
 maybe_dump_tags (FILE *stream)
 {
-  register int i;
+  size_t i;
 
   /* Emacs needs its TAGS file to be in Unix text format (i.e., only
      newline at end of every line, no CR), so when we generate a
@@ -254,7 +254,7 @@
   /* Print out the information for each block. */
   for (i = 0; i < emacs_tags_index; i++)
     {
-      register int j;
+      size_t j;
       register EMACS_TAG_BLOCK *block;
       register EMACS_TAG *etag;
       long block_len;
@@ -313,7 +313,7 @@
   tag->line = line;
   tag->char_offset = char_offset;
   add_pointer_to_array (tag, block->entries_index, block->entries,
-                        block->entries_slots, 50, EMACS_TAG *);
+                        block->entries_slots, 50);
 }
 
 /* Read the file represented by FILENAME into core, and search it for Info
@@ -542,7 +542,7 @@
      free the memory already allocated to it. */
   if (block->entries)
     add_pointer_to_array (block, emacs_tags_index, emacs_tags,
-                          emacs_tags_slots, 10, EMACS_TAG_BLOCK *);
+                          emacs_tags_slots, 10);
   else
     {
       free (block->filename);

Modified: trunk/info/man.c
===================================================================
--- trunk/info/man.c    2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/man.c    2013-08-20 19:15:05 UTC (rev 5334)
@@ -541,8 +541,8 @@
 {
   SEARCH_BINDING *reference_section;
   REFERENCE **refs = NULL;
-  int refs_index = 0;
-  int refs_slots = 0;
+  size_t refs_index = 0;
+  size_t refs_slots = 0;
   long position;
 
   reference_section = find_reference_section (node);
@@ -594,8 +594,7 @@
           entry->start = start;
           entry->end = end;
 
-          add_pointer_to_array
-            (entry, refs_index, refs, refs_slots, 10, REFERENCE *);
+          add_pointer_to_array (entry, refs_index, refs, refs_slots, 10);
         }
 
       reference_section->start = position + 1;
@@ -654,12 +653,12 @@
 REFERENCE **
 manpage_xrefs_in_binding (NODE *node, SEARCH_BINDING *binding)
 {
-  register int i;
+  size_t i;
   REFERENCE **all_refs = xrefs_of_manpage (node);
   REFERENCE **brefs = NULL;
   REFERENCE *entry;
-  int brefs_index = 0;
-  int brefs_slots = 0;
+  size_t brefs_index = 0;
+  size_t brefs_slots = 0;
   int start, end;
 
   if (!all_refs)
@@ -671,8 +670,7 @@
   for (i = 0; (entry = all_refs[i]); i++)
     {
       if ((entry->start > start) && (entry->end < end))
-        add_pointer_to_array (entry, brefs_index, brefs, brefs_slots, 10, 
-                              REFERENCE *);
+        add_pointer_to_array (entry, brefs_index, brefs, brefs_slots, 10);
       else
         info_reference_free (entry);
     }

Modified: trunk/info/nodemenu.c
===================================================================
--- trunk/info/nodemenu.c       2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/nodemenu.c       2013-08-20 19:15:05 UTC (rev 5334)
@@ -132,7 +132,7 @@
   INFO_WINDOW *info_win;
   NODE *node;
   char **lines = NULL;
-  int lines_index = 0, lines_slots = 0;
+  size_t lines_index = 0, lines_slots = 0;
 
   if (!info_windows)
     return NULL;
@@ -153,8 +153,7 @@
               char *line;
 
               line = format_node_info (node);
-              add_pointer_to_array
-                (line, lines_index, lines, lines_slots, 20, char *);
+              add_pointer_to_array (line, lines_index, lines, lines_slots, 20);
             }
         }
     }

Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c  2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/nodes.c  2013-08-20 19:15:05 UTC (rev 5334)
@@ -66,7 +66,7 @@
 FILE_BUFFER **info_loaded_files = NULL;
 
 /* The number of slots currently allocated to LOADED_FILES. */
-int info_loaded_files_slots = 0;
+size_t info_loaded_files_slots = 0;
 
 /* Public functions for node manipulation.  */
 
@@ -517,7 +517,7 @@
 get_nodes_of_info_file (FILE_BUFFER *file_buffer)
 {
   long nodestart;
-  int tags_index = 0;
+  size_t tags_index = 0;
   SEARCH_BINDING binding;
 
   binding.buffer = file_buffer->contents;
@@ -585,7 +585,7 @@
 
       /* Add this tag to the array of tag structures in this FILE_BUFFER. */
       add_pointer_to_array (entry, tags_index, file_buffer->tags,
-                            file_buffer->tags_slots, 100, TAG *);
+                            file_buffer->tags_slots, 100);
     }
 }
 
@@ -614,7 +614,7 @@
   int name_offset;
   SEARCH_BINDING *tmp_search;
   long position;
-  int tags_index = 0;
+  size_t tags_index = 0;
 
   tmp_search = copy_binding (buffer_binding);
 
@@ -698,7 +698,7 @@
       /* Add this node structure to the array of node structures in this
          FILE_BUFFER. */
       add_pointer_to_array (entry, tags_index, file_buffer->tags,
-                            file_buffer->tags_slots, 100, TAG *);
+                            file_buffer->tags_slots, 100);
     }
   free (tmp_search);
 }
@@ -719,7 +719,7 @@
 {
   int i;
   SUBFILE **subfiles = NULL;
-  int subfiles_index = 0, subfiles_slots = 0;
+  size_t subfiles_index = 0, subfiles_slots = 0;
   TAG *entry;
 
   /* First get the list of tags from the tags table.  Then lookup the
@@ -751,8 +751,8 @@
         subfile->filename[colon - 1] = 0;
         subfile->first_byte = (long) atol (line + colon);
 
-        add_pointer_to_array
-          (subfile, subfiles_index, subfiles, subfiles_slots, 10, SUBFILE *);
+        add_pointer_to_array (subfile, subfiles_index, subfiles, 
+                              subfiles_slots, 10);
 
         while (*line++ != '\n');
       }
@@ -1113,7 +1113,7 @@
     ;
 
   add_pointer_to_array (file_buffer, i, info_loaded_files,
-                        info_loaded_files_slots, 10, FILE_BUFFER *);
+                        info_loaded_files_slots, 10);
 }
 
 /* Forget the contents, tags table, nodes list, and names of FILENAME. */

Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h  2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/nodes.h  2013-08-20 19:15:05 UTC (rev 5334)
@@ -110,7 +110,7 @@
   size_t filesize;              /* The number of bytes this file expands to. */
   char **subfiles;              /* If non-null, the list of subfiles. */
   TAG **tags;                   /* If non-null, the indirect tags table. */
-  int tags_slots;               /* Number of slots allocated for TAGS. */
+  size_t tags_slots;            /* Number of slots allocated for TAGS. */
   int flags;                    /* Various flags.  Mimics of N_* flags. */
 } FILE_BUFFER;
 
@@ -120,7 +120,7 @@
 extern FILE_BUFFER **info_loaded_files;
 
 /* The number of slots currently allocated to INFO_LOADED_FILES. */
-extern int info_loaded_files_slots;
+extern size_t info_loaded_files_slots;
 
 /* Locate the file named by FILENAME, and return the information structure
    describing this file.  The file may appear in our list of loaded files

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/session.c        2013-08-20 19:15:05 UTC (rev 5334)
@@ -64,10 +64,10 @@
 INFO_WINDOW **info_windows = NULL;
 
 /* Where to add the next window, if we need to add one. */
-static int info_windows_index = 0;
+static size_t info_windows_index = 0;
 
 /* Number of slots allocated to `info_windows'. */
-static int info_windows_slots = 0;
+static size_t info_windows_slots = 0;
 
 /* Whether to use regexps or not for search.  */
 static int use_regex = 1;
@@ -366,7 +366,7 @@
       info_win->nodes_slots = 0;
 
       add_pointer_to_array (info_win, info_windows_index, info_windows,
-                            info_windows_slots, 10, INFO_WINDOW *);
+                            info_windows_slots, 10);
     }
 
   /* If this node, the current pagetop, and the current point are the
@@ -409,7 +409,7 @@
 static void
 consistency_check_info_windows (void)
 {
-  register int i;
+  size_t i;
 
   for (i = 0; i < info_windows_index; i++)
     {
@@ -429,7 +429,7 @@
 void
 forget_window_and_nodes (WINDOW *window)
 {
-  register int i;
+  size_t i;
   INFO_WINDOW *info_win = NULL;
 
   for (i = 0; info_windows && (info_win = info_windows[i]); i++)
@@ -458,8 +458,8 @@
               free (info_win->nodes[i]);
           free (info_win->nodes);
 
-          maybe_free (info_win->pagetops);
-          maybe_free (info_win->points);
+          free (info_win->pagetops);
+          free (info_win->points);
         }
 
       free (info_win);
@@ -2071,7 +2071,7 @@
           node = info_get_node (entry->label, "Top", PARSE_NODE_DFLT);
           if (!node && info_recent_file_error)
             {
-              maybe_free (file_system_error);
+              free (file_system_error);
               file_system_error = xstrdup (info_recent_file_error);
             }
         }
@@ -2085,9 +2085,9 @@
         info_error (msg_cant_find_node, nodename);
     }
 
-  maybe_free (file_system_error);
-  maybe_free (filename);
-  maybe_free (nodename);
+  free (file_system_error);
+  free (filename);
+  free (nodename);
 
   if (node)
     info_set_node_of_window (1, window, node);
@@ -2547,7 +2547,7 @@
       /* User aborts, just quit. */
       if (!line)
         {
-          maybe_free (defentry);
+          free (defentry);
           info_free_references (menu);
           info_abort_key (window, 0, 0);
           return;
@@ -2732,8 +2732,8 @@
     register int fbi, i;
     FILE_BUFFER *current;
     REFERENCE **items = NULL;
-    int items_index = 0;
-    int items_slots = 0;
+    size_t items_index = 0;
+    size_t items_slots = 0;
 
     current = file_buffer_of_window (window);
 
@@ -2751,8 +2751,7 @@
         entry->label = xmalloc (4 + strlen (fb->filename));
         sprintf (entry->label, "(%s)*", fb->filename);
 
-        add_pointer_to_array
-          (entry, items_index, items, items_slots, 10, REFERENCE *);
+        add_pointer_to_array (entry, items_index, items, items_slots, 10);
 
         if (fb->tags)
           {
@@ -2771,8 +2770,8 @@
                              fb->filename, fb->tags[i]->nodename);
                   }
 
-                add_pointer_to_array
-                  (entry, items_index, items, items_slots, 100, REFERENCE *);
+                add_pointer_to_array (entry, items_index, items, 
+                                      items_slots, 100);
               }
           }
       }
@@ -3280,7 +3279,7 @@
   char *nodename;
   INFO_WINDOW *info_win;
   REFERENCE **menu = NULL;
-  int menu_index = 0, menu_slots = 0;
+  size_t menu_index = 0, menu_slots = 0;
   char *default_nodename = xstrdup (active_window->node->nodename);
   char *prompt = xmalloc (strlen (_("Kill node (%s): ")) + strlen 
(default_nodename));
 
@@ -3292,8 +3291,7 @@
       entry->label = xstrdup (info_win->window->node->nodename);
       entry->filename = entry->nodename = NULL;
 
-      add_pointer_to_array (entry, menu_index, menu, menu_slots, 10,
-                            REFERENCE *);
+      add_pointer_to_array (entry, menu_index, menu, menu_slots, 10);
     }
 
   nodename = info_read_completing_in_echo_area (window, prompt, menu);
@@ -4316,8 +4314,8 @@
 
 /* Array of search states. */
 static SEARCH_STATE **isearch_states = NULL;
-static int isearch_states_index = 0;
-static int isearch_states_slots = 0;
+static size_t isearch_states_index = 0;
+static size_t isearch_states_slots = 0;
 
 /* Push the state of this search. */
 static void
@@ -4332,7 +4330,7 @@
   state->failing = failing;
 
   add_pointer_to_array (state, isearch_states_index, isearch_states,
-                        isearch_states_slots, 20, SEARCH_STATE *);
+                        isearch_states_slots, 20);
 }
 
 /* Pop the state of this search to WINDOW, SEARCH_INDEX, and DIRECTION. */
@@ -4414,7 +4412,7 @@
            p_rep ? p_rep : "");
 
   window_message_in_echo_area ("%s", prompt);
-  maybe_free (p_rep);
+  free (p_rep);
   free (prompt);
   display_cursor_at_point (active_window);
 }
@@ -4597,7 +4595,7 @@
              then push it into pending input. */
           if (isearch_string_index && func != (VFunction *) info_abort_key)
             {
-              maybe_free (last_isearch_accepted);
+              free (last_isearch_accepted);
               last_isearch_accepted = xstrdup (isearch_string);
             }
 

Modified: trunk/info/variables.c
===================================================================
--- trunk/info/variables.c      2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/variables.c      2013-08-20 19:15:05 UTC (rev 5334)
@@ -166,8 +166,8 @@
       {
         register int i;
         REFERENCE **array = NULL;
-        int array_index = 0;
-        int array_slots = 0;
+        size_t array_index = 0;
+        size_t array_slots = 0;
 
         for (i = 0; var->choices[i]; i++)
           {
@@ -178,8 +178,7 @@
             entry->nodename = NULL;
             entry->filename = NULL;
 
-            add_pointer_to_array
-              (entry, array_index, array, array_slots, 10, REFERENCE *);
+            add_pointer_to_array (entry, array_index, array, array_slots, 10);
           }
 
         sprintf (prompt, _("Set %s to value (%s): "),
@@ -272,7 +271,7 @@
 {
   register int i;
   REFERENCE **array = NULL;
-  int array_index = 0, array_slots = 0;
+  size_t array_index = 0, array_slots = 0;
 
   for (i = 0; info_variables[i].name; i++)
     {
@@ -283,8 +282,7 @@
       entry->nodename = NULL;
       entry->filename = NULL;
 
-      add_pointer_to_array
-        (entry, array_index, array, array_slots, 200, REFERENCE *);
+      add_pointer_to_array (entry, array_index, array, array_slots, 200);
     }
 
   return array;

Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2013-08-20 18:06:38 UTC (rev 5333)
+++ trunk/info/window.c 2013-08-20 19:15:05 UTC (rev 5334)
@@ -137,8 +137,8 @@
       if (!windows->next)
         {
           windows->height = 0;
-          maybe_free (windows->line_starts);
-         maybe_free (windows->log_line_no);
+          free (windows->line_starts);
+         free (windows->log_line_no);
           windows->line_starts = NULL;
           windows->line_count = 0;
           break;
@@ -186,7 +186,7 @@
       if ((win->width != width) && ((win->flags & W_InhibitMode) == 0))
         {
           win->width = width;
-          maybe_free (win->modeline);
+          free (win->modeline);
           win->modeline = xmalloc (1 + width);
         }
 
@@ -605,8 +605,8 @@
       if (old_pagetop == window->pagetop)
         display_scroll_line_starts
           (window, old_pagetop, old_starts, old_lines);
-      maybe_free (old_starts);
-      maybe_free (old_xlat);
+      free (old_starts);
+      free (old_xlat);
     }
   window->flags |= W_UpdateWindow;
 }
@@ -862,8 +862,8 @@
 void
 recalculate_line_starts (WINDOW *window)
 {
-  maybe_free (window->line_starts);
-  maybe_free (window->log_line_no);
+  free (window->line_starts);
+  free (window->log_line_no);
   calculate_line_starts (window);
 }
 
@@ -1174,7 +1174,7 @@
 {
   if (echo_area_node)
     {
-      maybe_free (echo_area_node->contents);
+      free (echo_area_node->contents);
       free (echo_area_node);
     }
 
@@ -1219,8 +1219,8 @@
    any existing message.  A future call to unmessage_in_echo_area ()
    restores the old contents. */
 static NODE **old_echo_area_nodes = NULL;
-static int old_echo_area_nodes_index = 0;
-static int old_echo_area_nodes_slots = 0;
+static size_t old_echo_area_nodes_index = 0;
+static size_t old_echo_area_nodes_slots = 0;
 
 void
 message_in_echo_area (const char *format, ...)
@@ -1231,7 +1231,7 @@
     {
       add_pointer_to_array (echo_area_node, old_echo_area_nodes_index,
                             old_echo_area_nodes, old_echo_area_nodes_slots,
-                            4, NODE *);
+                            4);
     }
   echo_area_node = NULL;
   va_start (ap, format);




reply via email to

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