*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / cp-namespace.c
index 65d3ecc47468e5e0c3444d3f38d3e055a9121b6e..910289ff3ce579a76242c862c1196745df5474ec 100644 (file)
@@ -603,7 +603,7 @@ static struct type *
 cp_lookup_transparent_type_loop (const char *name, const char *scope,
                                 int length)
 {
-  int scope_length = cp_find_first_component (scope + length);
+  int scope_length = length + cp_find_first_component (scope + length);
   char *full_name;
 
   /* If the current scope is followed by "::", look in the next
@@ -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.
This page took 0.025023 seconds and 4 git commands to generate.