summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/rocklib.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2013-08-22 12:12:47 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2013-08-26 09:42:47 +0200
commita2a2e14e0d400e1c82b4d02c4399602488578dc6 (patch)
tree87e63279ef95ce06315b492d85a009b58f3782b2 /apps/plugins/lua/rocklib.c
parentb2e80edd1671833dc80eb0c5334cb6a2c58808e0 (diff)
downloadrockbox-a2a2e14e0d400e1c82b4d02c4399602488578dc6.tar.gz
rockbox-a2a2e14e0d400e1c82b4d02c4399602488578dc6.zip
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
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r--apps/plugins/lua/rocklib.c12
1 files changed, 6 insertions, 6 deletions
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,
522 int i; 522 int i;
523 luaL_checktype(L, pos, LUA_TTABLE); 523 luaL_checktype(L, pos, LUA_TTABLE);
524 int n = luaL_getn(L, pos); 524 int n = luaL_getn(L, pos);
525 const char **lines = (const char**) dlmalloc(n * sizeof(const char*)); 525 const char **lines = (const char**) tlsf_malloc(n * sizeof(const char*));
526 if(lines == NULL) 526 if(lines == NULL)
527 luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*)); 527 luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*));
528 for(i=1; i<=n; i++) 528 for(i=1; i<=n; i++)
@@ -548,11 +548,11 @@ RB_WRAP(gui_syncyesno_run)
548 548
549 enum yesno_res result = rb->gui_syncyesno_run(&main_message, yes, no); 549 enum yesno_res result = rb->gui_syncyesno_run(&main_message, yes, no);
550 550
551 dlfree(main_message.message_lines); 551 tlsf_free(main_message.message_lines);
552 if(yes) 552 if(yes)
553 dlfree(yes_message.message_lines); 553 tlsf_free(yes_message.message_lines);
554 if(no) 554 if(no)
555 dlfree(no_message.message_lines); 555 tlsf_free(no_message.message_lines);
556 556
557 lua_pushinteger(L, result); 557 lua_pushinteger(L, result);
558 return 1; 558 return 1;
@@ -571,7 +571,7 @@ RB_WRAP(do_menu)
571 start_selected = luaL_optint(L, 3, 0); 571 start_selected = luaL_optint(L, 3, 0);
572 572
573 n = luaL_getn(L, 2); 573 n = luaL_getn(L, 2);
574 items = (const char**) dlmalloc(n * sizeof(const char*)); 574 items = (const char**) tlsf_malloc(n * sizeof(const char*));
575 if(items == NULL) 575 if(items == NULL)
576 luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*)); 576 luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*));
577 for(i=1; i<=n; i++) 577 for(i=1; i<=n; i++)
@@ -587,7 +587,7 @@ RB_WRAP(do_menu)
587 587
588 int result = rb->do_menu(&menu, &start_selected, NULL, false); 588 int result = rb->do_menu(&menu, &start_selected, NULL, false);
589 589
590 dlfree(items); 590 tlsf_free(items);
591 591
592 lua_pushinteger(L, result); 592 lua_pushinteger(L, result);
593 return 1; 593 return 1;