From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14680 invoked by alias); 8 Aug 2017 15:22:34 -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 14643 invoked by uid 89); 8 Aug 2017 15:22:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=HCc:D*ca X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Aug 2017 15:22:31 +0000 Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id E95DB10AF0F; Tue, 8 Aug 2017 11:22:29 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 2/3] Replace remaining cleanups in fbsd-nat.c. Date: Tue, 08 Aug 2017 15:22:00 -0000 Message-ID: <4557151.QeCK76vByr@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: References: <20170808061917.73979-1-jhb@FreeBSD.org> <20170808061917.73979-3-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00149.txt.bz2 On Tuesday, August 08, 2017 11:16:28 AM Simon Marchi wrote: > 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? Well, this calls an API in a system library that allocates memory via libc's malloc() and requires it to be free'd via libc's free() rather than any interpositions. Thus, it isn't allocated via xmalloc() and that is why the existing code uses free() rather than xfree(). > > @@ -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 > :). Oh, duh. > Otherwise, gdb::byte_vector with a .resize() would probably be > appropriate to use here. Ok, I'll rework it with that. -- John Baldwin