aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-30 15:49:19 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-30 15:49:19 -0200
commitd1c689af402e847f77dbe164265e097e90bdc61a (patch)
tree15280b1d60381277d904049ced37b07ded8ad6ac /lobject.h
parent37e9c2e74486ed443151430a9b73a3844d3554ef (diff)
downloadlua-d1c689af402e847f77dbe164265e097e90bdc61a.tar.gz
lua-d1c689af402e847f77dbe164265e097e90bdc61a.tar.bz2
lua-d1c689af402e847f77dbe164265e097e90bdc61a.zip
subtelties in layout of TString
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/lobject.h b/lobject.h
index 402eec40..dde9f9b5 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.80 2000/10/26 12:47:05 roberto Exp roberto $ 2** $Id: lobject.h,v 1.81 2000/10/30 16:29:59 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -71,9 +71,16 @@ typedef struct lua_TObject {
71/* 71/*
72** String headers for string table 72** String headers for string table
73*/ 73*/
74
75/*
76** most `malloc' libraries allocate memory in blocks of 8 bytes. TSPACK
77** tries to make sizeof(TString) a multiple of this granularity, to reduce
78** waste of space.
79*/
80#define TSPACK ((int)sizeof(int))
81
74typedef struct TString { 82typedef struct TString {
75 union { 83 union {
76 union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
77 struct { /* for strings */ 84 struct { /* for strings */
78 unsigned long hash; 85 unsigned long hash;
79 int constindex; /* hint to reuse constants */ 86 int constindex; /* hint to reuse constants */
@@ -85,8 +92,8 @@ typedef struct TString {
85 } u; 92 } u;
86 size_t len; 93 size_t len;
87 struct TString *nexthash; /* chain for hash table */ 94 struct TString *nexthash; /* chain for hash table */
88 unsigned char marked; 95 int marked;
89 char str[1]; /* variable length string!! must be the last field! */ 96 char str[TSPACK]; /* variable length string!! must be the last field! */
90} TString; 97} TString;
91 98
92 99