From d2e340f467a46017fa3526074c1756124e569880 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 9 Feb 2001 18:22:29 -0200 Subject: string pointers are always fully aligned --- lobject.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lobject.h') diff --git a/lobject.h b/lobject.h index 215ab4a8..c46e0cb1 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.93 2001/02/02 15:13:05 roberto Exp roberto $ +** $Id: lobject.h,v 1.94 2001/02/02 16:32:00 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -57,7 +57,6 @@ typedef struct lua_TObject { #define clvalue(o) ((o)->value.cl) #define hvalue(o) ((o)->value.h) #define infovalue(o) ((o)->value.info) -#define svalue(o) (tsvalue(o)->str) /* Macros to set values */ @@ -91,13 +90,6 @@ typedef struct lua_TObject { ** String headers for string table */ -/* -** most `malloc' libraries allocate memory in blocks of 8 bytes. TSPACK -** tries to make sizeof(TString) a multiple of this granularity, to reduce -** waste of space. -*/ -#define TSPACK ((int)sizeof(int)) - typedef struct TString { union { struct { /* for strings */ @@ -112,10 +104,23 @@ typedef struct TString { size_t len; int marked; struct TString *nexthash; /* chain for hash table */ - char str[TSPACK]; /* variable length string!! must be the last field! */ } TString; +/* +** type equivalent to TString, but with maximum alignment requirements +*/ +union L_UTString { + TString ts; + union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ +}; + + + +#define getstr(ts) ((char *)(ts) + sizeof(union L_UTString)) +#define svalue(o) getstr(tsvalue(o)) + + /* ** Function Prototypes */ -- cgit v1.2.3-55-g6feb