summaryrefslogtreecommitdiff
path: root/firmware/core_alloc.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-10-05 18:32:19 +0000
committerThomas Martitz <kugel@rockbox.org>2011-10-05 18:32:19 +0000
commit4478b25ede0129b1572145737627db7297dcc89f (patch)
tree26e30d0021ee7d3433ec055c4576cb24f14d9080 /firmware/core_alloc.c
parent6efb3f0760b54fb80423924a7aab17da043dbba9 (diff)
core_alloc: Provide a tiny test allocation, which can be freed for debug purposes.
This allocation can be freed in the buflib debug menu (select it to free). Doing a another allocation, e.g. by selecting another item in this debug menu will cause compaction (all allocs move). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30719 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/core_alloc.c')
-rw-r--r--firmware/core_alloc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/firmware/core_alloc.c b/firmware/core_alloc.c
index 2250f5c664..21dd1319dd 100644
--- a/firmware/core_alloc.c
+++ b/firmware/core_alloc.c
@@ -6,6 +6,9 @@
/* not static so it can be discovered by core_get_data() */
struct buflib_context core_ctx;
+
+/* debug test alloc */
+static int test_alloc;
void core_allocator_init(void)
{
buffer_init();
@@ -13,6 +16,17 @@ void core_allocator_init(void)
void *start = buffer_get_buffer(&size);
buflib_init(&core_ctx, start, size);
buffer_release_buffer(size);
+
+ test_alloc = core_alloc("test", 112);
+}
+
+bool core_test_free(void)
+{
+ bool ret = test_alloc > 0;
+ if (ret)
+ test_alloc = core_free(test_alloc);
+
+ return ret;
}
int core_alloc(const char* name, size_t size)