diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-07-12 05:23:52 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-28 15:17:48 +0200 |
commit | 45bd14b392622cb58e967a24e4652c510b3d43e4 (patch) | |
tree | 22bd2e5cafc2d82ecc4773f83de7f86515b4db43 /apps/plugins/lua/ltable.c | |
parent | 4beafe16fafc2e5c59734ef065a6f8d23766520d (diff) | |
download | rockbox-45bd14b392622cb58e967a24e4652c510b3d43e4.tar.gz rockbox-45bd14b392622cb58e967a24e4652c510b3d43e4.zip |
Lua Add Emergency Garbage Collector
Derivative of work by RobertGabrielJakabosky
http://lua-users.org/wiki/EmergencyGarbageCollector
I've only implemented the not enough memory part and
expanded this idea to adding a mechanism to signal
the OOM condition of the plugin buffer which allows us to only
grab the playback buffer after garbage collection fails
(SO THE MUSIC KEEPS PLAYING AS LONG AS POSSIBLE)
Change-Id: I684fb98b540ffc01f7ba324ab5b761ceb59b9f9b
Diffstat (limited to 'apps/plugins/lua/ltable.c')
-rw-r--r-- | apps/plugins/lua/ltable.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/apps/plugins/lua/ltable.c b/apps/plugins/lua/ltable.c index ec84f4fabc..31162fe7c1 100644 --- a/apps/plugins/lua/ltable.c +++ b/apps/plugins/lua/ltable.c | |||
@@ -358,6 +358,8 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { | |||
358 | Table *luaH_new (lua_State *L, int narray, int nhash) { | 358 | Table *luaH_new (lua_State *L, int narray, int nhash) { |
359 | Table *t = luaM_new(L, Table); | 359 | Table *t = luaM_new(L, Table); |
360 | luaC_link(L, obj2gco(t), LUA_TTABLE); | 360 | luaC_link(L, obj2gco(t), LUA_TTABLE); |
361 | sethvalue2s(L, L->top, t); /* put table on stack */ | ||
362 | incr_top(L); | ||
361 | t->metatable = NULL; | 363 | t->metatable = NULL; |
362 | t->flags = cast_byte(~0); | 364 | t->flags = cast_byte(~0); |
363 | /* temporary values (kept only if some malloc fails) */ | 365 | /* temporary values (kept only if some malloc fails) */ |
@@ -367,6 +369,7 @@ Table *luaH_new (lua_State *L, int narray, int nhash) { | |||
367 | t->node = cast(Node *, dummynode); | 369 | t->node = cast(Node *, dummynode); |
368 | setarrayvector(L, t, narray); | 370 | setarrayvector(L, t, narray); |
369 | setnodevector(L, t, nhash); | 371 | setnodevector(L, t, nhash); |
372 | L->top--; /* remove table from stack */ | ||
370 | return t; | 373 | return t; |
371 | } | 374 | } |
372 | 375 | ||