* cp-namespace.c (check_one_possible_namespace_symbol): Don't use
authorDaniel Jacobowitz <drow@false.org>
Mon, 9 Feb 2004 22:19:26 +0000 (22:19 +0000)
committerDaniel Jacobowitz <drow@false.org>
Mon, 9 Feb 2004 22:19:26 +0000 (22:19 +0000)
obstack_free.

gdb/ChangeLog
gdb/cp-namespace.c

index afb0dc207a4ef016ee28e293266c5564758379d1..5ef59fc682bfb6d3b89dbc0c7d912ae48f5befb3 100644 (file)
@@ -1,3 +1,8 @@
+2004-02-09  Daniel Jacobowitz  <drow@mvista.com>
+
+       * cp-namespace.c (check_one_possible_namespace_symbol): Don't use
+       obstack_free.
+
 2004-02-09  Andrew Cagney  <cagney@redhat.com>
 
        * blockframe.c (find_pc_partial_function): If find_pc_overlay
index 65d3ecc47468e5e0c3444d3f38d3e055a9121b6e..a731352c6e49bffc0ebe106bfe5c4a46519f5bee 100644 (file)
@@ -783,14 +783,20 @@ check_one_possible_namespace_symbol (const char *name, int len,
                                     struct objfile *objfile)
 {
   struct block *block = get_possible_namespace_block (objfile);
-  char *name_copy = obsavestring (name, len, &objfile->objfile_obstack);
-  struct symbol *sym = lookup_block_symbol (block, name_copy, NULL,
-                                           VAR_DOMAIN);
+  char *name_copy = alloca (len + 1);
+  struct symbol *sym;
+
+  memcpy (name_copy, name, len);
+  name_copy[len] = '\0';
+  sym = lookup_block_symbol (block, name_copy, NULL, VAR_DOMAIN);
 
   if (sym == NULL)
     {
-      struct type *type = init_type (TYPE_CODE_NAMESPACE, 0, 0,
-                                    name_copy, objfile);
+      struct type *type;
+      name_copy = obsavestring (name, len, &objfile->objfile_obstack);
+
+      type = init_type (TYPE_CODE_NAMESPACE, 0, 0, name_copy, objfile);
+
       TYPE_TAG_NAME (type) = TYPE_NAME (type);
 
       sym = obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
@@ -806,11 +812,7 @@ check_one_possible_namespace_symbol (const char *name, int len,
       return 0;
     }
   else
-    {
-      obstack_free (&objfile->objfile_obstack, name_copy);
-
-      return 1;
-    }
+    return 1;
 }
 
 /* Look for a symbol named NAME in all the possible namespace blocks.