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 8DC483857C4A for ; Sun, 9 Aug 2020 22:34:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8DC483857C4A 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 [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C07DF1E554; Sun, 9 Aug 2020 18:34:13 -0400 (EDT) Subject: Re: [PATCH 1/6] Remove some manual memory management from compile interface To: Tom Tromey , gdb-patches@sourceware.org References: <20200809135258.8207-1-tom@tromey.com> <20200809135258.8207-2-tom@tromey.com> From: Simon Marchi Message-ID: <6824ff00-ef2a-c1dc-8717-75111d3fd8b0@simark.ca> Date: Sun, 9 Aug 2020 18:34:05 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200809135258.8207-2-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, 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: Sun, 09 Aug 2020 22:34:15 -0000 > diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c > index 02df7ab90e6..00eaaf3fa68 100644 > --- a/gdb/compile/compile-cplus-types.c > +++ b/gdb/compile/compile-cplus-types.c > @@ -848,33 +848,33 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance, > gcc_type result; > if (type->code () == TYPE_CODE_STRUCT) > { > - struct gcc_vbase_array bases; > int num_baseclasses = TYPE_N_BASECLASSES (type); > + std::vector elements (num_baseclasses); > + std::vector flags (num_baseclasses); > > - memset (&bases, 0, sizeof (bases)); > + struct gcc_vbase_array bases {}; > + bases.elements = elements.data (); > > if (num_baseclasses > 0) You could now remove this `if (num_baseclasses > 0)`, there's no reason for it anymore I think. Otherwise, LGTM. Simon