From af77f2cd7af1fa65a414c86767366bae95892e69 Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 19 Jan 2015 15:15:49 -0500 Subject: libqos: Split apart pc_alloc_init Move the list-specific initialization over into malloc.c, to keep all of the list implementation details within the same file. The allocation and freeing of these structures are now both back within the same layer. Signed-off-by: John Snow Reviewed-by: Paolo Bonzini Message-id: 1421698563-6977-2-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi --- tests/libqos/malloc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/libqos/malloc.c') diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c index 5debf18497..0d34ecd4b6 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; +} -- cgit 1.4.1