Use unique_xmalloc_ptr in c_type_print_base
authorTom Tromey <tom@tromey.com>
Thu, 2 Nov 2017 01:16:58 +0000 (19:16 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 4 Nov 2017 16:27:19 +0000 (10:27 -0600)
This changes c_type_print_base to use unique_xmalloc_ptr, removing a
cleanup.

gdb/ChangeLog
2017-11-04  Tom Tromey  <tom@tromey.com>

* c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.

gdb/ChangeLog
gdb/c-typeprint.c

index d4b10a35b53c982b3f2e4271e993e57f2e58c84f..04fee5e586c2718d9208e3b54960c57b43c4a55d 100644 (file)
@@ -1,3 +1,7 @@
+2017-11-04  Tom Tromey  <tom@tromey.com>
+
+       * c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
+
 2017-11-04  Tom Tromey  <tom@tromey.com>
 
        * linux-tdep.c (linux_core_info_proc_mappings): Use
index 22fdaa5beb7badbbeb6b2f5aa60005ab0ab89b24..ed5a1a4b8a4f965ad8b2e2f3f4bd020d9c166ec3 100644 (file)
@@ -1218,8 +1218,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
              for (j = 0; j < len2; j++)
                {
                  const char *mangled_name;
+                 gdb::unique_xmalloc_ptr<char> mangled_name_holder;
                  char *demangled_name;
-                 struct cleanup *inner_cleanup;
                  const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
                  int is_full_physname_constructor =
                    TYPE_FN_FIELD_CONSTRUCTOR (f, j)
@@ -1231,8 +1231,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                  if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
                    continue;
 
-                 inner_cleanup = make_cleanup (null_cleanup, NULL);
-
                  QUIT;
                  section_type = output_access_specifier
                    (stream, section_type, level,
@@ -1265,12 +1263,9 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                    }
                  if (TYPE_FN_FIELD_STUB (f, j))
                    {
-                     char *tem;
-
                      /* Build something we can demangle.  */
-                     tem = gdb_mangle_name (type, i, j);
-                     make_cleanup (xfree, tem);
-                     mangled_name = tem;
+                     mangled_name_holder.reset (gdb_mangle_name (type, i, j));
+                     mangled_name = mangled_name_holder.get ();
                    }
                  else
                    mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
@@ -1328,8 +1323,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      xfree (demangled_name);
                    }
 
-                 do_cleanups (inner_cleanup);
-
                  fprintf_filtered (stream, ";\n");
                }
            }