summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/rocklib.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-11-11 18:27:19 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-07-11 00:31:41 +0200
commitc6fcb1cf45b249b059c2d53a062f9a6c7f449047 (patch)
tree229eacd12461605a8320eb7590ff83eea13538d6 /apps/plugins/lua/rocklib.c
parent42240f6990156fb907a7dce7258be2f1235fab44 (diff)
downloadrockbox-c6fcb1cf45b249b059c2d53a062f9a6c7f449047.zip
rockbox-c6fcb1cf45b249b059c2d53a062f9a6c7f449047.tar.gz
rockbox-c6fcb1cf45b249b059c2d53a062f9a6c7f449047.tar.bz2
rockbox-c6fcb1cf45b249b059c2d53a062f9a6c7f449047.tar.xz
lua inbinary strings
Allows saving of ram by reusing strings already stored in the binary and storing a pointer instead of malloc and copy to get them inside the lua state Saves about 1.5K overall Derivative of work by bogdanm RAM optimizations: pseudo RO strings, functions in Flash https://github.com/elua/elua/commit/d54659b5723bcd2b1e3900362398c72c18a9aa0b Change-Id: I21d6dcfa32523877efd9f70fb0f88f2a02872649
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r--apps/plugins/lua/rocklib.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 9ad6411..426dd07 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -25,6 +25,7 @@
#define LUA_LIB
#include "lua.h"
+#include "lstring.h"
#include "lauxlib.h"
#include "rocklib.h"
@@ -835,6 +836,7 @@ LUALIB_API int luaopen_rock(lua_State *L)
static const struct lua_int_reg* rlci = rlib_const_int;
for (; rlci->name; rlci++) {
lua_pushinteger(L, rlci->value);
+ luaS_newlloc(L, rlci->name, TSTR_INBIN);
lua_setfield(L, -2, rlci->name);
}
@@ -853,7 +855,9 @@ LUALIB_API int luaopen_rock(lua_State *L)
static const struct lua_str_reg* rlcs = rlib_const_str;
for (; rlcs->name; rlcs++) {
+ luaS_newlloc(L, rlcs->value, TSTR_INBIN);
lua_pushstring(L, rlcs->value);
+ luaS_newlloc(L, rlcs->name, TSTR_INBIN);
lua_setfield(L, -2, rlcs->name);
}