[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Maximum alignment question
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 13 Feb 2009 17:34:26 -0200
> In lobject.h, the first member of TString (dummy) is used to force
> maximum alignment:
>
> /*
> ** String headers for string table
> */
> typedef union TString {
> L_Umaxalign dummy; /* ensures maximum alignment for strings */
> struct {
> CommonHeader;
> lu_byte reserved;
> unsigned int hash;
> size_t len;
> } tsv;
> } TString;
>
> My question is, why is this necessary? I looked through the code, but
> couldn't figure this out.
The manual says:
lua_tolstring returns a fully aligned pointer to a string inside the
Lua state.
The string itself is stored just after this structure:
#define getstr(ts) cast(const char *, (ts) + 1)
-- Roberto