From a2a2e14e0d400e1c82b4d02c4399602488578dc6 Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Thu, 22 Aug 2013 12:12:47 +0200 Subject: lua: Switch memory allocator from dl to tlsf Instead of providing yet another memory allocator implementation use tlsf and simply link tlsf library. Another small improvement is to *grow* memory pool by grabbing audiobuffer instead of just switching to use audiobuf exclusively. Tested with simple lua 'memory eater' script. This patch extends tlsf lib slightly. You can provide void *get_new_area(size_t * size) function which will override weak dummy implementation provided in lib itself. This allows to automaticaly initialize memory pool as well as grow memory pool if needed (for example grab audiobuffer when pluginbuffer is exhaused). Change-Id: I841af6b6b5bbbf546c14cbf139a7723fbb982f1b --- apps/plugins/lua/rocklib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'apps/plugins/lua/rocklib.c') diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index d89f48fa39..1290a7f298 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c @@ -522,7 +522,7 @@ static void fill_text_message(lua_State *L, struct text_message * message, int i; luaL_checktype(L, pos, LUA_TTABLE); int n = luaL_getn(L, pos); - const char **lines = (const char**) dlmalloc(n * sizeof(const char*)); + const char **lines = (const char**) tlsf_malloc(n * sizeof(const char*)); if(lines == NULL) luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*)); for(i=1; i<=n; i++) @@ -548,11 +548,11 @@ RB_WRAP(gui_syncyesno_run) enum yesno_res result = rb->gui_syncyesno_run(&main_message, yes, no); - dlfree(main_message.message_lines); + tlsf_free(main_message.message_lines); if(yes) - dlfree(yes_message.message_lines); + tlsf_free(yes_message.message_lines); if(no) - dlfree(no_message.message_lines); + tlsf_free(no_message.message_lines); lua_pushinteger(L, result); return 1; @@ -571,7 +571,7 @@ RB_WRAP(do_menu) start_selected = luaL_optint(L, 3, 0); n = luaL_getn(L, 2); - items = (const char**) dlmalloc(n * sizeof(const char*)); + items = (const char**) tlsf_malloc(n * sizeof(const char*)); if(items == NULL) luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*)); for(i=1; i<=n; i++) @@ -587,7 +587,7 @@ RB_WRAP(do_menu) int result = rb->do_menu(&menu, &start_selected, NULL, false); - dlfree(items); + tlsf_free(items); lua_pushinteger(L, result); return 1; -- cgit v1.2.3