summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/rocklib.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-05-03 23:06:40 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-05-03 23:13:25 -0400
commit9b2f23319c5ac84927774fca02b99bbb98057ebd (patch)
tree26392ade25f9a251f67bf9a2093a71d0e59e65f9 /apps/plugins/lua/rocklib.c
parent489a5f3ff72802fac20ca7459620101cd263bd1a (diff)
downloadrockbox-9b2f23319c5ac84927774fca02b99bbb98057ebd.tar.gz
rockbox-9b2f23319c5ac84927774fca02b99bbb98057ebd.zip
lua fix yellow and add temploader
temp loader allows some lua requires to be loaded and later garbage collected unfortunately the module needs to be formatted in such a way to pass back a call table in order to keep the functions within from being garbage collected too early BE AWARE this bypasses the module loader which would allow code reuse so if you aren't careful this memory saving tool could spell disaster for free RAM if you load the same code multiple times Change-Id: I0b6f81e481b8c779edbd620c8403794f8353926f
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r--apps/plugins/lua/rocklib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 050fbc73b2..2672d446fc 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -153,7 +153,7 @@ RB_WRAP(kbd_input)
153 153
154 const char *input = lua_tostring(L, 1); 154 const char *input = lua_tostring(L, 1);
155 size_t layout_len; 155 size_t layout_len;
156 const char *layout = lua_tolstring(L, 2, &layout_len); 156 const unsigned char *layout = lua_tolstring(L, 2, &layout_len);
157 char *buffer = luaL_prepbuffer(&b); 157 char *buffer = luaL_prepbuffer(&b);
158 158
159 if(input != NULL) 159 if(input != NULL)
@@ -161,8 +161,12 @@ RB_WRAP(kbd_input)
161 else 161 else
162 buffer[0] = '\0'; 162 buffer[0] = '\0';
163 163
164 if(layout_len <= 1 || (unsigned short)layout[layout_len - 1] != 0xFFFE) 164 if(layout_len <= 2 ||
165 layout[layout_len - 1] != 0xFE ||
166 layout[layout_len - 2] != 0xFF)
167 {
165 layout = NULL; 168 layout = NULL;
169 }
166 170
167 if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (unsigned short *)layout)) 171 if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (unsigned short *)layout))
168 { 172 {