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: Anthony Liguori
Subject: Re: [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc
Date: Wed, 13 Mar 2013 09:53:41 -0500
User-agent: Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

Kevin Wolf <address@hidden> writes:

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

Definitely.

Regard,

Anthony Liguori

>
> Kevin




reply via email to

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