summaryrefslogtreecommitdiffstats
path: root/apps/tagtree.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-08-30 14:01:33 +0000
committerThomas Martitz <kugel@rockbox.org>2011-08-30 14:01:33 +0000
commitd0b72e25903574acb1cf9184a6052cdd646dbc37 (patch)
tree5be8db5ee00b2a727e4821cf51a5f7bcf3991073 /apps/tagtree.c
parentc940811ade7d99a0e0d414df7c6509672413684a (diff)
downloadrockbox-d0b72e25903574acb1cf9184a6052cdd646dbc37.tar.gz
rockbox-d0b72e25903574acb1cf9184a6052cdd646dbc37.tar.bz2
rockbox-d0b72e25903574acb1cf9184a6052cdd646dbc37.zip
GSoC/Buflib: Add buflib memory alocator to the core.
The buflib memory allocator is handle based and can free and compact, move or resize memory on demand. This allows to effeciently allocate memory dynamically without an MMU, by avoiding fragmentation through memory compaction. This patch adds the buflib library to the core, along with convinience wrappers to omit the context parameter. Compaction is not yet enabled, but will be in a later patch. Therefore, this acts as a replacement for buffer_alloc/buffer_get_buffer() with the benifit of a debug menu. See buflib.h for some API documentation. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30380 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 5012c084d0..0d4330bac8 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -44,7 +44,7 @@
#include "playlist.h"
#include "keyboard.h"
#include "gui/list.h"
-#include "buffer.h"
+#include "core_alloc.h"
#include "yesno.h"
#include "misc.h"
#include "filetypes.h"
@@ -176,9 +176,14 @@ static int current_entry_count;
static struct tree_context *tc;
/* a few memory alloc helper */
+static int tagtree_handle;
+static size_t tagtree_bufsize, tagtree_buf_used;
static void* tagtree_alloc(size_t size)
{
- return buffer_alloc(size);
+ char* buf = core_get_data(tagtree_handle) + tagtree_buf_used;
+ size = ALIGN_UP(size, sizeof(void*));
+ tagtree_buf_used += size;
+ return buf;
}
static void* tagtree_alloc0(size_t size)
@@ -1035,6 +1040,7 @@ void tagtree_init(void)
menu_count = 0;
menu = NULL;
rootmenu = -1;
+ tagtree_handle = core_alloc_maximum("tagtree", &tagtree_bufsize, NULL);
parse_menu(FILE_SEARCH_INSTRUCTIONS);
/* If no root menu is set, assume it's the first single menu
@@ -1046,6 +1052,8 @@ void tagtree_init(void)
add_event(PLAYBACK_EVENT_TRACK_BUFFER, false, tagtree_buffer_event);
add_event(PLAYBACK_EVENT_TRACK_FINISH, false, tagtree_track_finish_event);
+
+ core_shrink(tagtree_handle, core_get_data(tagtree_handle), tagtree_buf_used);
}
static bool show_search_progress(bool init, int count)