V5.5: Thanks for great new "fixed ROM option" for BIN code

126 views
Skip to first unread message

bil til

unread,
Oct 9, 2025, 1:38:48 PM (9 days ago) Oct 9
to lu...@googlegroups.com
This worked now much easier than I thought:

I just modified one line in function f_parser in ldo.c to:

const char *mode = p->mode ? p->mode : "Bt";

(the default mode here would usually be "bt", and switching this to
"Bt" seems to be fine to allow Lua code file loading (then binary goes
to RAM) and Lua bin file loading (then binary keeps in ROM)). (in
original code it is "bt", then the complete binary ROM code will be
copied to RAM - so large code will eat up much RAM...).

This is great news for me, as typically my single chip controllers
have quite abundant ROM but quite sparse RAM... .

A "simple" question: Is it a good idea, to do this "one-line" code
modification at this point? Or would you better recommend it in some
"upper function"?

Roberto Ierusalimschy

unread,
Oct 12, 2025, 10:32:31 AM (6 days ago) Oct 12
to lu...@googlegroups.com
> I just modified one line in function f_parser in ldo.c to:
>
> const char *mode = p->mode ? p->mode : "Bt";
>
> [...]
>
> A "simple" question: Is it a good idea, to do this "one-line" code
> modification at this point? Or would you better recommend it in some
> "upper function"?

Note that, in general, buffers can live in memory that is not "fixed",
and Lua has no way to check whether a "fixed" buffer is actually fixed.
So, to make the default for everyone assumes that any binary chunk lives
in fixed memory seems too error-prone. It is better to make the user
declare explicitly, when calling luaL_loadbufferx (or similar), whether
the buffer is fixed.

-- Roberto

bil til

unread,
Oct 12, 2025, 11:42:04 PM (5 days ago) Oct 12
to lu...@googlegroups.com
So now I moved this modification to LuaL_loadfileex:
if( !mode)
mode= "Bt";

Thanks.

Am So., 12. Okt. 2025 um 16:32 Uhr schrieb Roberto Ierusalimschy
<rob...@inf.puc-rio.br>:
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/20251012143223.GA1068260%40arraial.inf.puc-rio.br.
Reply all
Reply to author
Forward
0 new messages