From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xh3AX-0004xO-8T for qemu-devel@nongnu.org; Wed, 22 Oct 2014 17:10:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xh3AO-0001Mj-76 for qemu-devel@nongnu.org; Wed, 22 Oct 2014 17:10:09 -0400 Received: from mail-wg0-x232.google.com ([2a00:1450:400c:c00::232]:60812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xh3AN-0001M3-VQ for qemu-devel@nongnu.org; Wed, 22 Oct 2014 17:10:00 -0400 Received: by mail-wg0-f50.google.com with SMTP id a1so4631267wgh.21 for ; Wed, 22 Oct 2014 14:09:58 -0700 (PDT) Date: Wed, 22 Oct 2014 23:09:54 +0200 From: Marc =?UTF-8?B?TWFyw60=?= Message-ID: <20141022230954.6e847daa@crunchbang> In-Reply-To: <5447DC61.50005@redhat.com> References: <1413624257-7714-1-git-send-email-marc.mari.barcelo@gmail.com> <5447DC61.50005@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] libqos: Convert malloc-pc allocator to a generic allocator List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: qemu-devel@nongnu.org > > +void alloc_uninit(QGuestAllocator *allocator) > > +{ > > + MemBlock *node; > > + MemBlock *tmp; > > + QAllocOpts mask; > > + > > + /* Check for guest leaks, and destroy the list. */ > > + QTAILQ_FOREACH_SAFE(node, &allocator->used, MLIST_ENTNAME, > > tmp) { > > + if (allocator->opts & (ALLOC_LEAK_WARN | > > ALLOC_LEAK_ASSERT)) { > > + fprintf(stderr, "guest malloc leak @ 0x%016" PRIx64 "; > > " > > + "size 0x%016" PRIx64 ".\n", > > + node->addr, node->size); > > + } > > + if (allocator->opts & (ALLOC_LEAK_ASSERT)) { > > + g_assert_not_reached(); > > + } > > + g_free(node); > > + } > > + > > + /* If we have previously asserted that there are no leaks, > > then there > > + * should be only one node here with a specific address and > > size. */ > > + mask = ALLOC_LEAK_ASSERT | ALLOC_PARANOID; > > + QTAILQ_FOREACH_SAFE(node, &allocator->free, MLIST_ENTNAME, > > tmp) { > > + if ((allocator->opts & mask) == mask) { > > + if ((node->addr != allocator->start) || > > + (node->size != allocator->end - allocator->start)) > > { > > + fprintf(stderr, "Free list is corrupted.\n"); > > + g_assert_not_reached(); > > + } > > + } > > + > > + g_free(node); > > + } > > +} > > The original malloc-pc implementation for alloc_uninit() also deletes > the QGuestAllocator here, but this version doesn't, which creates a > small leak. Did you have a different cleanup pathway in mind? When moving things, that free got lost, a little typo. I'll resend tomorrow morning. Thanks.