aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos/malloc-pc.h
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2014-08-01 11:38:58 -0400
committerStefan Hajnoczi <stefanha@redhat.com>2014-09-08 11:12:43 +0100
commitec2f160538a24b72767e2afd1f0ba3085a35b79d (patch)
treeb94718ea238b83be87eeabfdfa945f5b8130c664 /tests/libqos/malloc-pc.h
parent53b33231f76e85984eb18a4c63fd132d0d4e3f40 (diff)
downloadqemu-ec2f160538a24b72767e2afd1f0ba3085a35b79d.zip
qemu-ec2f160538a24b72767e2afd1f0ba3085a35b79d.tar.gz
qemu-ec2f160538a24b72767e2afd1f0ba3085a35b79d.tar.bz2
libqos: add a simple first-fit memory allocator
Implement a simple first-fit memory allocator that attempts to keep track of leased blocks of memory in order to be able to re-use blocks. Additionally, allow the user to specify when initializing the device that upon cleanup, we would like to assert that there are no blocks in use. This may be useful for identifying problems in qtests that use more complicated set-up and tear-down routines. This functionality is used in my upcoming ahci-test v2 patch set, but I didn't see fit to enable it for any existing tests, which will continue to operate the same as they have prior. Signed-off-by: John Snow <jsnow@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/libqos/malloc-pc.h')
-rw-r--r--tests/libqos/malloc-pc.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/libqos/malloc-pc.h b/tests/libqos/malloc-pc.h
index ff964ab..9f525e3 100644
--- a/tests/libqos/malloc-pc.h
+++ b/tests/libqos/malloc-pc.h
@@ -15,6 +15,15 @@
#include "libqos/malloc.h"
+typedef enum {
+ PC_ALLOC_NO_FLAGS = 0x00,
+ PC_ALLOC_LEAK_WARN = 0x01,
+ PC_ALLOC_LEAK_ASSERT = 0x02,
+ PC_ALLOC_PARANOID = 0x04
+} PCAllocOpts;
+
QGuestAllocator *pc_alloc_init(void);
+QGuestAllocator *pc_alloc_init_flags(PCAllocOpts flags);
+void pc_alloc_uninit(QGuestAllocator *allocator);
#endif