From patchwork Thu Nov 2 22:36:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 24050 Received: (qmail 7545 invoked by alias); 2 Nov 2017 22:36:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7464 invoked by uid 89); 2 Nov 2017 22:36:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=rfa X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.144.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Nov 2017 22:36:19 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 85408197A18 for ; Thu, 2 Nov 2017 17:36:18 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id AO5yeIl1cpOTvAO5ye4Kpl; Thu, 02 Nov 2017 17:36:18 -0500 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:58978 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eAO5y-003CfJ-Aq; Thu, 02 Nov 2017 17:36:18 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 11/13] Use unique_xmalloc_ptr in c_type_print_base Date: Thu, 2 Nov 2017 16:36:10 -0600 Message-Id: <20171102223612.3642-12-tom@tromey.com> In-Reply-To: <20171102223612.3642-1-tom@tromey.com> References: <20171102223612.3642-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eAO5y-003CfJ-Aq X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya.Home) [71.218.90.63]:58978 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This changes c_type_print_base to use unique_xmalloc_ptr, removing a cleanup. gdb/ChangeLog 2017-11-02 Tom Tromey * c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr. --- gdb/ChangeLog | 4 ++++ gdb/c-typeprint.c | 13 +++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 22fdaa5beb..ed5a1a4b8a 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -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 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"); } }