qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc


From: Kevin Wolf
Subject: Re: [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc
Date: Wed, 13 Mar 2013 14:44:28 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Am 05.03.2013 um 14:53 hat Anthony Liguori geschrieben:
> Signed-off-by: Anthony Liguori <address@hidden>

> --- /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?

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]