Kevin Wolf <kw...@redhat.com> writes: > Am 05.03.2013 um 14:53 hat Anthony Liguori geschrieben: >> Signed-off-by: Anthony Liguori <aligu...@us.ibm.com> > >> --- /dev/null >> +++ b/tests/libqos/malloc.h >> @@ -0,0 +1,26 @@ >> +#ifndef LIBQOS_MALLOC_H >> +#define LIBQOS_MALLOC_H >> + >> +#include <stdint.h> >> +#include <sys/types.h> >> + >> +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?
Definitely. Regard, Anthony Liguori > > Kevin