diff options
Diffstat (limited to 'tests/libqos/malloc.c')
-rw-r--r-- | tests/libqos/malloc.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c index 5debf18..0d34ecd 100644 --- a/tests/libqos/malloc.c +++ b/tests/libqos/malloc.c @@ -268,3 +268,20 @@ void guest_free(QGuestAllocator *allocator, uint64_t addr) mlist_check(allocator); } } + +QGuestAllocator *alloc_init(uint64_t start, uint64_t end) +{ + QGuestAllocator *s = g_malloc0(sizeof(*s)); + MemBlock *node; + + s->start = start; + s->end = end; + + QTAILQ_INIT(&s->used); + QTAILQ_INIT(&s->free); + + node = mlist_new(s->start, s->end - s->start); + QTAILQ_INSERT_HEAD(&s->free, node, MLIST_ENTNAME); + + return s; +} |