2 * libqos malloc support
4 * Copyright IBM, Corp. 2012-2013
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef LIBQOS_MALLOC_H
14 #define LIBQOS_MALLOC_H
17 #include <sys/types.h>
19 typedef struct QGuestAllocator QGuestAllocator
;
21 struct QGuestAllocator
23 uint64_t (*alloc
)(QGuestAllocator
*allocator
, size_t size
);
24 void (*free
)(QGuestAllocator
*allocator
, uint64_t addr
);
27 /* Always returns page aligned values */
28 static inline uint64_t guest_alloc(QGuestAllocator
*allocator
, size_t size
)
30 return allocator
->alloc(allocator
, size
);
33 static inline void guest_free(QGuestAllocator
*allocator
, uint64_t addr
)
35 allocator
->alloc(allocator
, addr
);