From ef3008bb372af09f87d6685ea7ce46a177a61362 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Mon, 27 Apr 2026 02:01:27 +0200 Subject: [PATCH] fix(lua): pack TValue and TKey structs to reduce RAM usage (#7289) --- radio/src/thirdparty/Lua/src/lobject.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/radio/src/thirdparty/Lua/src/lobject.h b/radio/src/thirdparty/Lua/src/lobject.h index db9bf7c1a..e55e15683 100644 --- a/radio/src/thirdparty/Lua/src/lobject.h +++ b/radio/src/thirdparty/Lua/src/lobject.h @@ -117,20 +117,18 @@ typedef union Value { } Value; -#define TValuefields Value value_; int tt_ +#define TValuefields Value value_; lu_byte tt_ -// #ifdef LUA_USE_ESP -// # pragma pack(4) -// #endif +#if defined(__GNUC__) || defined(__clang__) +#define LUA_PACKED __attribute__((__packed__)) +#else +#define LUA_PACKED +#endif -typedef struct lua_TValue { +typedef struct LUA_PACKED lua_TValue { TValuefields; } TValue; -// #ifdef LUA_USE_ESP -// # pragma pack() -// #endif - /* macro defining a nil value */ #define NILCONSTANT {NULL}, LUA_TNIL @@ -509,7 +507,7 @@ typedef union Closure { */ typedef union TKey { - struct { + struct LUA_PACKED { TValuefields; int next; /* for chaining (offset for next node) */ } nk;