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/README | 10 - apps/plugins/lua/SOURCES | 2 +- apps/plugins/lua/lua.make | 6 +- apps/plugins/lua/malloc.c | 5056 ---------------------------------------- apps/plugins/lua/rockconf.h | 9 +- apps/plugins/lua/rocklib.c | 12 +- apps/plugins/lua/rocklua.c | 3 - apps/plugins/lua/rockmalloc.c | 63 - apps/plugins/lua/rockmalloc.h | 46 - apps/plugins/lua/tlsf_helper.c | 48 + lib/tlsf/src/tlsf.c | 14 +- 11 files changed, 73 insertions(+), 5196 deletions(-) delete mode 100644 apps/plugins/lua/malloc.c delete mode 100644 apps/plugins/lua/rockmalloc.c delete mode 100644 apps/plugins/lua/rockmalloc.h create mode 100644 apps/plugins/lua/tlsf_helper.c diff --git a/apps/plugins/lua/README b/apps/plugins/lua/README index db6933f517..5b53eb354e 100644 --- a/apps/plugins/lua/README +++ b/apps/plugins/lua/README @@ -9,13 +9,3 @@ version 0.31 which is licensed under the GPL version 2: strtol.c strtoul.c strstr.c - -The malloc routine is Doug Lea's malloc with the following license: - - Version 2.8.3 Thu Sep 22 11:16:15 2005 Doug Lea (dl at gee) - - This is a version (aka dlmalloc) of malloc/free/realloc written by - Doug Lea and released to the public domain, as explained at - http://creativecommons.org/licenses/publicdomain. Send questions, - comments, complaints, performance data, etc to dl@cs.oswego.edu - diff --git a/apps/plugins/lua/SOURCES b/apps/plugins/lua/SOURCES index 048999d2d1..baebfabe65 100644 --- a/apps/plugins/lua/SOURCES +++ b/apps/plugins/lua/SOURCES @@ -28,7 +28,7 @@ lvm.c lzio.c rockaux.c rocklib.c -rockmalloc.c +tlsf_helper.c fscanf.c gmtime.c strcspn.c diff --git a/apps/plugins/lua/lua.make b/apps/plugins/lua/lua.make index a70f0280b0..f81bf00074 100644 --- a/apps/plugins/lua/lua.make +++ b/apps/plugins/lua/lua.make @@ -30,7 +30,7 @@ else ROCKS += $(LUA_BUILDDIR)/lua.rock endif -$(LUA_BUILDDIR)/lua.rock: $(LUA_OBJ) $(LUA_BUILDDIR)/actions.lua $(LUA_BUILDDIR)/buttons.lua $(LUA_BUILDDIR)/rocklib_aux.o +$(LUA_BUILDDIR)/lua.rock: $(LUA_OBJ) $(TLSFLIB) $(LUA_BUILDDIR)/actions.lua $(LUA_BUILDDIR)/buttons.lua $(LUA_BUILDDIR)/rocklib_aux.o $(LUA_BUILDDIR)/actions.lua: $(LUA_OBJ) $(LUA_SRCDIR)/action_helper.pl $(call PRINTS,GEN $(@F))$(CC) $(PLUGINFLAGS) $(INCLUDES) -E $(APPSDIR)/plugins/lib/pluginlib_actions.h | $(LUA_SRCDIR)/action_helper.pl > $(LUA_BUILDDIR)/actions.lua @@ -45,13 +45,13 @@ $(LUA_BUILDDIR)/rocklib_aux.c: $(APPSDIR)/plugin.h $(LUA_OBJ) $(LUA_SRCDIR)/rock $(LUA_BUILDDIR)/rocklib_aux.o: $(LUA_BUILDDIR)/rocklib_aux.c $(call PRINTS,CC $(