Fix -Werror -Wuninitialized warnings.
[deliverable/binutils-gdb.git] / gdb / symtab.c
index 9f6fb56cf2060895dd21ea71fc2aa6588da801c0..515612e5ba66f5ec797761c6e2cc95010d978046 100644 (file)
@@ -1,5 +1,6 @@
 /* Symbol table lookup for the GNU debugger, GDB.
-   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -595,7 +596,7 @@ lookup_symbol (const char *name, const struct block *block,
   returnval = lookup_symbol_aux (modified_name, block, namespace,
                                 is_a_field_of_this, symtab);
   if (needtofreename)
-    free (modified_name2);
+    xfree (modified_name2);
 
   return returnval;     
 }
@@ -771,8 +772,8 @@ lookup_symbol_aux (const char *name, const struct block *block,
            {
              /* This is a mangled variable, look it up by its
                 mangled name.  */
-             return lookup_symbol (SYMBOL_NAME (msymbol), block,
-                                   namespace, is_a_field_of_this, symtab);
+             return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
+                                       namespace, is_a_field_of_this, symtab);
            }
          /* There are no debug symbols for this file, or we are looking
             for an unmangled variable.
@@ -949,8 +950,8 @@ lookup_symbol_aux (const char *name, const struct block *block,
                   && MSYMBOL_TYPE (msymbol) != mst_file_text
                   && !STREQ (name, SYMBOL_NAME (msymbol)))
            {
-             return lookup_symbol (SYMBOL_NAME (msymbol), block,
-                                   namespace, is_a_field_of_this, symtab);
+             return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
+                                       namespace, is_a_field_of_this, symtab);
            }
        }
     }
@@ -998,13 +999,13 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
        {
          center = bottom + (top - bottom) / 2;
          if (!(center < top))
-           abort ();
+           internal_error (__FILE__, __LINE__, "failed internal consistency check");
          if (!do_linear_search
              && (SYMBOL_LANGUAGE (*center) == language_java))
            {
              do_linear_search = 1;
            }
-         if (STRCMP (SYMBOL_SOURCE_NAME (*center), name) >= 0)
+         if (strcmp (SYMBOL_SOURCE_NAME (*center), name) >= 0)
            {
              top = center;
            }
@@ -1014,7 +1015,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
            }
        }
       if (!(top == bottom))
-       abort ();
+       internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
       /* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
         we don't have to force a linear search on C++. Probably holds true
@@ -1237,7 +1238,7 @@ lookup_block_symbol (register const struct block *block, const char *name,
            {
              top = inc;
            }
-         else if (STRCMP (SYMBOL_SOURCE_NAME (sym), name) < 0)
+         else if (strcmp (SYMBOL_SOURCE_NAME (sym), name) < 0)
            {
              bot = inc;
            }
@@ -1259,8 +1260,11 @@ lookup_block_symbol (register const struct block *block, const char *name,
       while (bot < top)
        {
          sym = BLOCK_SYM (block, bot);
-         if (SYMBOL_MATCHES_NAME (sym, name))
-           return sym;
+         if (SYMBOL_NAMESPACE (sym) == namespace &&
+             SYMBOL_MATCHES_NAME (sym, name))
+           {
+             return sym;
+           }
          bot++;
        }
     }
@@ -2278,7 +2282,7 @@ free_search_symbols (struct symbol_search *symbols)
   for (p = symbols; p != NULL; p = next)
     {
       next = p->next;
-      free (p);
+      xfree (p);
     }
 }
 
@@ -2345,7 +2349,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
   struct symbol_search *tail;
   struct cleanup *old_chain = NULL;
 
-  if (kind < LABEL_NAMESPACE)
+  if (kind < VARIABLES_NAMESPACE)
     error ("must search on specific namespace");
 
   ourtype = types[(int) (kind - VARIABLES_NAMESPACE)];
@@ -2637,7 +2641,7 @@ print_symbol_info (namespace_enum kind, struct symtab *s, struct symbol *sym,
       else
        {
          fputs_filtered (demangled_name, stream);
-         free (demangled_name);
+         xfree (demangled_name);
        }
 #endif
     }
@@ -2876,7 +2880,7 @@ completion_list_add_name (char *symname, char *sym_text, int sym_text_len,
          {
            if (STREQ (new, return_val[i]))
              {
-               free (new);
+               xfree (new);
                return;
              }
          }
@@ -3183,7 +3187,7 @@ overload_list_add_symbol (struct symbol *sym, char *oload_name)
   /* skip symbols that cannot match */
   if (strcmp (sym_name, oload_name) != 0)
     {
-      free (sym_name);
+      xfree (sym_name);
       return;
     }
 
@@ -3206,7 +3210,7 @@ overload_list_add_symbol (struct symbol *sym, char *oload_name)
   sym_return_val[sym_return_val_index++] = sym;
   sym_return_val[sym_return_val_index] = NULL;
 
-  free (sym_name);
+  xfree (sym_name);
 }
 
 /* Return a null-terminated list of pointers to function symbols that
@@ -3327,7 +3331,7 @@ make_symbol_overload_list (struct symbol *fsym)
       }
   }
 
-  free (oload_name);
+  xfree (oload_name);
 
   return (sym_return_val);
 }
This page took 0.028406 seconds and 4 git commands to generate.