[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] libqos: Convert malloc-pc allocator to a generi
From: |
Marc Marí |
Subject: |
Re: [Qemu-devel] [PATCH] libqos: Convert malloc-pc allocator to a generic allocator |
Date: |
Wed, 22 Oct 2014 23:09:54 +0200 |
> > +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.