From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73891 invoked by alias); 8 Aug 2017 09:16:42 -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 73877 invoked by uid 89); 8 Aug 2017 09:16:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=resize X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Aug 2017 09:16:39 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v789GWTT004850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 8 Aug 2017 05:16:37 -0400 Received: by simark.ca (Postfix, from userid 112) id 8D1151EA1C; Tue, 8 Aug 2017 05:16:32 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 308861E9AB; Tue, 8 Aug 2017 05:16:28 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 08 Aug 2017 09:16:00 -0000 From: Simon Marchi To: John Baldwin Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/3] Replace remaining cleanups in fbsd-nat.c. In-Reply-To: <20170808061917.73979-3-jhb@FreeBSD.org> References: <20170808061917.73979-1-jhb@FreeBSD.org> <20170808061917.73979-3-jhb@FreeBSD.org> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 8 Aug 2017 09:16:32 +0000 X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00142.txt.bz2 Hi John, > @@ -84,20 +92,17 @@ fbsd_find_memory_regions (struct target_ops *self, > find_memory_region_ftype func, void *obfd) > { > pid_t pid = ptid_get_pid (inferior_ptid); > - struct kinfo_vmentry *vmentl, *kve; > + struct kinfo_vmentry *kve; > uint64_t size; > - struct cleanup *cleanup; > int i, nitems; > > - vmentl = kinfo_getvmmap (pid, &nitems); > + std::unique_ptr kinfo_vmentry>> > + vmentl (kinfo_getvmmap (pid, &nitems)); Doesn't this essentially do the same thing as gdb::unique_xmalloc_ptr, since xfree calls free? > @@ -392,7 +392,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum > target_object object, > #endif > case TARGET_OBJECT_AUXV: > { > - struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); > + gdb::unique_xmalloc_ptr buf_storage(nullptr); You don't need to initialize explicitly to nullptr, that's the default value. But if you still want to, then add a space before parenthesis :). Otherwise, gdb::byte_vector with a .resize() would probably be appropriate to use here. Thanks, Simon