From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway36.websitewelcome.com (gateway36.websitewelcome.com [192.185.192.36]) by sourceware.org (Postfix) with ESMTPS id 0CBD03857C4B for ; Sat, 18 Jul 2020 17:29:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0CBD03857C4B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 2D36C400C8B6F for ; Sat, 18 Jul 2020 11:52:08 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id wqeFjQSyhwgQAwqeFjX9tH; Sat, 18 Jul 2020 12:29:19 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jvRCLQ3zpCD88qOEiSuTSfU3PT3VlR8MZbSFkb1ZlR0=; b=KjXkXJeTzseXeqHRONFQTqbI2f x6ywTGWssIoovVbQ9IU4wriawpAdLqQpfpzmDa+yqmR321P+1L66yk7uxjPAEaJoeDPhY8XokLdDE E6mZ41Imrpdzom7HZuwVZwC6w; Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:56458 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1jwqeF-000fmD-EU; Sat, 18 Jul 2020 11:29:19 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/9] Use htab_up in linespec.c Date: Sat, 18 Jul 2020 11:29:11 -0600 Message-Id: <20200718172915.6811-6-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200718172915.6811-1-tom@tromey.com> References: <20200718172915.6811-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.104.48 X-Source-L: No X-Exim-ID: 1jwqeF-000fmD-EU X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya.Home) [174.16.104.48]:56458 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3036.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jul 2020 17:29:21 -0000 This changes linespec.c to use htab_up rather than explicit calls to htab_delete. Note that a use still exists in this file, because linespec_state hasn't been converted to have a real destructor. gdb/ChangeLog 2020-07-18 Tom Tromey * linespec.c (class decode_compound_collector) <~decode_compound_collector>: Default. : Now htab_up. (decode_compound_collector::operator ()): Update. (class symtab_collector) <~symtab_collector>: Default. : Now htab_up. (symtab_collector::operator ()): Update. --- gdb/ChangeLog | 10 ++++++++++ gdb/linespec.c | 30 +++++++++++------------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 4a634e3aff9..57a6283a2d6 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3449,17 +3449,13 @@ class decode_compound_collector { public: decode_compound_collector () + : m_unique_syms (htab_create_alloc (1, htab_hash_pointer, + htab_eq_pointer, NULL, + xcalloc, xfree)) { - m_unique_syms = htab_create_alloc (1, htab_hash_pointer, - htab_eq_pointer, NULL, - xcalloc, xfree); } - ~decode_compound_collector () - { - if (m_unique_syms != NULL) - htab_delete (m_unique_syms); - } + ~decode_compound_collector () = default; /* Return all symbols collected. */ std::vector release_symbols () @@ -3473,7 +3469,7 @@ class decode_compound_collector private: /* A hash table of all symbols we found. We use this to avoid adding any symbol more than once. */ - htab_t m_unique_syms; + htab_up m_unique_syms; /* The result vector. */ std::vector m_symbols; @@ -3496,7 +3492,7 @@ decode_compound_collector::operator () (block_symbol *bsym) && t->code () != TYPE_CODE_NAMESPACE) return true; /* Continue iterating. */ - slot = htab_find_slot (m_unique_syms, sym, INSERT); + slot = htab_find_slot (m_unique_syms.get (), sym, INSERT); if (!*slot) { *slot = sym; @@ -3726,16 +3722,12 @@ class symtab_collector { public: symtab_collector () + : m_symtab_table (htab_create (1, htab_hash_pointer, htab_eq_pointer, + NULL)) { - m_symtab_table = htab_create (1, htab_hash_pointer, htab_eq_pointer, - NULL); } - ~symtab_collector () - { - if (m_symtab_table != NULL) - htab_delete (m_symtab_table); - } + ~symtab_collector () = default; /* Callable as a symbol_found_callback_ftype callback. */ bool operator () (symtab *sym); @@ -3751,7 +3743,7 @@ class symtab_collector std::vector m_symtabs; /* This is used to ensure the symtabs are unique. */ - htab_t m_symtab_table; + htab_up m_symtab_table; }; bool @@ -3759,7 +3751,7 @@ symtab_collector::operator () (struct symtab *symtab) { void **slot; - slot = htab_find_slot (m_symtab_table, symtab, INSERT); + slot = htab_find_slot (m_symtab_table.get (), symtab, INSERT); if (!*slot) { *slot = symtab; -- 2.17.2