2010-07-02 Ulrich Weigand <uweigand@de.ibm.com>
[binutils-gdb.git] / gdb / cp-valprint.c
index 209a7521d9f8f091e3aff10922ce555f30db15de..5f47ec4d9100d26b3e69bd6f843df177a8d192b2 100644 (file)
@@ -164,10 +164,19 @@ cp_print_value_fields (struct type *type, struct type *real_type,
   
   if (recurse == 0)
     {
+      /* Any object can be left on obstacks only during an unexpected error.  */
+
       if (obstack_object_size (&dont_print_statmem_obstack) > 0)
-       obstack_free (&dont_print_statmem_obstack, NULL);
+       {
+         obstack_free (&dont_print_statmem_obstack, NULL);
+         obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR));
+       }
       if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
-       obstack_free (&dont_print_stat_array_obstack, NULL);
+       {
+         obstack_free (&dont_print_stat_array_obstack, NULL);
+         obstack_begin (&dont_print_stat_array_obstack,
+                        32 * sizeof (struct type *));
+       }
     }
 
   fprintf_filtered (stream, "{");
@@ -615,7 +624,7 @@ cp_print_static_field (struct type *type,
       first_dont_print
        = (struct type **) obstack_base (&dont_print_stat_array_obstack);
       i = obstack_object_size (&dont_print_stat_array_obstack)
-       / sizeof (CORE_ADDR);
+       / sizeof (struct type *);
 
       while (--i >= 0)
        {
@@ -764,7 +773,7 @@ Show printing of object's derived type based on vtable info."), NULL,
                           show_objectprint,
                           &setprintlist, &showprintlist);
 
-  obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (CORE_ADDR));
+  obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (struct type *));
   obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR));
   obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
 }