From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127393 invoked by alias); 6 Apr 2018 19:29:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 127382 invoked by uid 89); 6 Apr 2018 19:29:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=day X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Apr 2018 19:29:33 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 522947C6DC; Fri, 6 Apr 2018 19:29:32 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC9E1215CDC6; Fri, 6 Apr 2018 19:29:31 +0000 (UTC) Subject: Re: [RFA 01/12] Introduce a gdb_ref_ptr specialization for struct value To: Tom Tromey , gdb-patches@sourceware.org References: <20180405211507.6103-1-tom@tromey.com> <20180405211507.6103-2-tom@tromey.com> From: Pedro Alves Message-ID: <6e1fc69d-daf7-1fe6-5fbb-5ea3748e1787@redhat.com> Date: Fri, 06 Apr 2018 19:29:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180405211507.6103-2-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-04/txt/msg00099.txt.bz2 On 04/05/2018 10:14 PM, Tom Tromey wrote: > struct value is internally reference counted and so, while it also has > some ownership rules unique to it, it makes sense to use a gdb_ref_ptr > when managing it automatically. > > This patch removes the existing unique_ptr specialization in favor of > a reference-counted pointer. It also introduces two other > clarifications: > > 1. Rename value_free to value_decref, which I think is more in line > with what the function actually does; and > > 2. Change release_value to return a gdb_ref_ptr. This change allows > us to remove the confusing release_value_or_incref function, > primarily by making it much simpler to reason about the result of > release_value. Yeah. As I was reading this patch, I was wondering whether release_value is going to score high in could-use-a-better-name charts. I.e., wondering whether code like this: release_value (v).release (); is likely to cause confusion. Maybe renaming it to be a bit more explicit would help. E.g.: release_from_value_chain (v).release (); or: move_out_of_value_chain (v).release (); But, the following patches eliminate the ".release()" calls, so it isn't that bad. Anyway, that was a thought for another rainy day, not for this patch. Thanks, Pedro Alves