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 6E70C387085D for ; Thu, 25 Jun 2020 18:42:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E70C387085D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id F30031E5F9; Thu, 25 Jun 2020 14:42:52 -0400 (EDT) Subject: Re: [PATCH] gdb: make inferior::terminal a unique ptr To: Pedro Alves , Simon Marchi , gdb-patches@sourceware.org References: <20200625155517.32173-1-simon.marchi@efficios.com> <362a9ac5-7417-8250-ff07-28d31df97f08@palves.net> From: Simon Marchi Message-ID: <7c472cde-988f-4e13-ccf9-d7144c4e593d@simark.ca> Date: Thu, 25 Jun 2020 14:42:52 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <362a9ac5-7417-8250-ff07-28d31df97f08@palves.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, 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: Thu, 25 Jun 2020 18:42:54 -0000 On 2020-06-25 1:32 p.m., Pedro Alves wrote: > On 6/25/20 4:55 PM, Simon Marchi via Gdb-patches wrote: >> This changes the inferior::terminal field to be a unique pointer, so its >> deallocation is automatically managed. >> >> gdb/ChangeLog: >> >> * inferior.h (struct inferior) : Change type to >> gdb::unique_xmalloc_ptr. >> * inferior.c (inferior::~inferior): Don't free inf->terminal. >> * infcmd.c (set_inferior_io_terminal): Don't free terminal >> field, adjust to unique pointer. >> (get_inferior_io_terminal): Adjust to unique pointer. >> > > LGTM. > > This reminds me of this patch: > > https://github.com/palves/gdb/commit/f240d57e3e659d13a01d9dda79120e2ce6bc7e74 > > IMO, the code is more readable with that. WDYT? I thought about doing something similar... but I limited myself to the original intent of removing the manual free-ing. Otherwise, it never ends, there is just an infinity of such refactors we can do. But I think your patch looks good. I'll push mine now. Simon