[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Memory Size of 1 Mio Point Polyline table?
- From: Viacheslav Usov <via.usov@...>
- Date: Tue, 25 Oct 2022 10:40:08 +0200
On Tue, Oct 25, 2022 at 7:47 AM bil til <biltil52@gmail.com> wrote:
> So if you set LUA_32BITS in case of a 32bit compiler
The key word here is "if".
> #define TValuefields Value value_; unsigned char tt_
>
> typedef union Value {
> struct GCObject *gc; /* collectable objects */
> void *p; /* light userdata */
> lua_CFunction f; /* light C functions */
> int i; /* integer numbers */
> float n; /* float numbers */
> } Value;
As already discussed, compilers would by default make structures at
least a multiple of 4 bytes on 32-bit platforms, thus struct {int foo;
char bar; } would be "wasting" at least three bytes. This is the
reason why Lua makes TValuefields a define rather than a struct,
because it is then fused with the other fields in derived structures,
thus recovering the wasted bytes.
This makes TValue 12 bytes on 32-bit platforms by default, which you
can check directly with printf("%d", sizeof TValue).
Cheers,
V.