From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFlyx-0001JL-LP for qemu-devel@nongnu.org; Wed, 13 Mar 2013 09:44:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFlyq-0006z0-JZ for qemu-devel@nongnu.org; Wed, 13 Mar 2013 09:44:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFlyq-0006yp-C1 for qemu-devel@nongnu.org; Wed, 13 Mar 2013 09:44:32 -0400 Date: Wed, 13 Mar 2013 14:44:28 +0100 From: Kevin Wolf Message-ID: <20130313134428.GH2309@dhcp-200-207.str.redhat.com> References: <1362491612-19226-1-git-send-email-aliguori@us.ibm.com> <1362491612-19226-9-git-send-email-aliguori@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1362491612-19226-9-git-send-email-aliguori@us.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Am 05.03.2013 um 14:53 hat Anthony Liguori geschrieben: > Signed-off-by: Anthony Liguori > --- /dev/null > +++ b/tests/libqos/malloc.h > @@ -0,0 +1,26 @@ > +#ifndef LIBQOS_MALLOC_H > +#define LIBQOS_MALLOC_H > + > +#include > +#include > + > +typedef struct QGuestAllocator QGuestAllocator; > + > +struct QGuestAllocator > +{ > + uint64_t (*alloc)(QGuestAllocator *allocator, size_t size); > + void (*free)(QGuestAllocator *allocator, uint64_t addr); > +}; > + > +/* Always returns page aligned values */ > +static inline uint64_t guest_alloc(QGuestAllocator *allocator, size_t size) > +{ > + return allocator->alloc(allocator, size); > +} > + > +static inline void guest_free(QGuestAllocator *allocator, uint64_t addr) > +{ > + allocator->alloc(allocator, addr); > +} I think the common case is using exactly one global allocator. Maybe worth convenience macros like in libqtest.h? Kevin