From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 792893858C01 for ; Tue, 10 Oct 2023 20:42:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 792893858C01 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5AA841E1A8; Tue, 10 Oct 2023 16:42:16 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 06/24] gdbsupport: make intrusive_list's disposer accept a reference Date: Tue, 10 Oct 2023 16:40:01 -0400 Message-ID: <20231010204213.111285-7-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231010204213.111285-1-simon.marchi@efficios.com> References: <20231010204213.111285-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3496.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: All the API of intrusive_list works with references to item, I'm not sure why the disposer used in intrusive_list::clear_and_dispose is different and receives a pointer. Change it to accept a reference instead. This helps simplify a bit a subsequent patch, and I don't see any downside to it. Change-Id: I380886cd4ddaf136fe532eb2744f9e69beb41283 --- gdb/inferior.c | 10 +++++----- gdb/unittests/intrusive_list-selftests.c | 4 ++-- gdbsupport/intrusive_list.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gdb/inferior.c b/gdb/inferior.c index efe57cceae3e..4a55970ccba1 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -262,13 +262,13 @@ inferior::find_thread (ptid_t ptid) void inferior::clear_thread_list () { - thread_list.clear_and_dispose ([=] (thread_info *thr) + thread_list.clear_and_dispose ([=] (thread_info &thr) { threads_debug_printf ("deleting thread %s", - thr->ptid.to_string ().c_str ()); - set_thread_exited (thr, {}, true /* silent */); - if (thr->deletable ()) - delete thr; + thr.ptid.to_string ().c_str ()); + set_thread_exited (&thr, {}, true /* silent */); + if (thr.deletable ()) + delete &thr; }); ptid_thread_map.clear (); } diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c index 1f85b3266830..d990c0878b35 100644 --- a/gdb/unittests/intrusive_list-selftests.c +++ b/gdb/unittests/intrusive_list-selftests.c @@ -692,9 +692,9 @@ struct intrusive_list_test list.push_back (b); list.push_back (c); - auto disposer = [&] (const item_type *item) + auto disposer = [&] (const item_type &item) { - disposer_seen.insert (item); + disposer_seen.insert (&item); disposer_calls++; }; list.clear_and_dispose (disposer); diff --git a/gdbsupport/intrusive_list.h b/gdbsupport/intrusive_list.h index 5e9243867d27..aea1922cabee 100644 --- a/gdbsupport/intrusive_list.h +++ b/gdbsupport/intrusive_list.h @@ -513,7 +513,7 @@ class intrusive_list { while (!this->empty ()) { - pointer p = &front (); + reference p = front (); pop_front (); disposer (p); } -- 2.42.0