lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Am Di., 25. Okt. 2022 um 10:40 Uhr schrieb Viacheslav Usov <>:
> 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

... yes, this is correct.

But if you pack these structs in a table list, you can do it either way... .

This depends how the table is programmed.

(using the attribute <packed> in C compiler (e. g. ARM-CC) for such
table struct array would skip those 3 "extra bytes". In this case then
you have to be careful, as your TValue fields are not aligned any
more. So to extract a TValue field, it will be ultimately required to
use memcpy... to copy the 5 bytes to an aligned TValue).

Thank you for pointing this out ... this I did not really check out
further in my lengthy checking above, how the indexed memory part of
tables is organized... this is a bit over my scope in the Lua source
code overview, I am frightened :) .

So still the question open, whether the polyline in Lua32 this would
consume 2x5MByte, or 2x8MByte... , you are perfectly right.