new field 'nilvalue' in struct 'global_State' to avoid the use of · lua/lua@b95e466 · GitHub
Skip to content

Commit b95e466

Browse files
committed
new field 'nilvalue' in struct 'global_State' to avoid the use of
addresses of static variables
1 parent d406d3d commit b95e466

5 files changed

Lines changed: 17 additions & 22 deletions

File tree

‎lapi.c‎

Lines changed: 10 additions & 13 deletions

‎lobject.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lobject.h,v 2.144 2018/06/01 17:40:38 roberto Exp roberto $
2+
** $Id: lobject.h,v 2.145 2018/06/15 14:14:20 roberto Exp roberto $
33
** Type definitions for Lua objects
44
** See Copyright Notice in lua.h
55
*/
@@ -144,9 +144,6 @@ typedef StackValue *StkId; /* index to stack elements */
144144
#define ttisstrictnil(o) checktag((o), LUA_TNIL)
145145

146146

147-
/* macro defining a nil value */
148-
#define NILCONSTANT {NULL}, LUA_TNIL
149-
150147
#define setnilvalue(obj) settt_(obj, LUA_TNIL)
151148

152149

‎lstate.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lstate.c,v 2.152 2018/05/29 18:02:51 roberto Exp roberto $
2+
** $Id: lstate.c,v 2.153 2018/06/01 17:40:38 roberto Exp roberto $
33
** Global State
44
** See Copyright Notice in lua.h
55
*/
@@ -345,6 +345,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
345345
g->twups = NULL;
346346
g->totalbytes = sizeof(LG);
347347
g->GCdebt = 0;
348+
setnilvalue(&g->nilvalue);
348349
setgcparam(g->gcpause, LUAI_GCPAUSE);
349350
setgcparam(g->gcstepmul, LUAI_GCMUL);
350351
g->gcstepsize = LUAI_GCSTEPSIZE;

‎lstate.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lstate.h,v 2.157 2018/02/25 12:43:52 roberto Exp roberto $
2+
** $Id: lstate.h,v 2.158 2018/03/16 15:33:34 roberto Exp roberto $
33
** Global State
44
** See Copyright Notice in lua.h
55
*/
@@ -148,6 +148,7 @@ typedef struct global_State {
148148
lu_mem GCestimate; /* an estimate of the non-garbage memory in use */
149149
stringtable strt; /* hash table for strings */
150150
TValue l_registry;
151+
TValue nilvalue; /* a nil value */
151152
unsigned int seed; /* randomized seed for hashes */
152153
lu_byte currentwhite;
153154
lu_byte gcstate; /* state of garbage collector */

‎ltm.c‎

Lines changed: 2 additions & 3 deletions

0 commit comments

Comments
 (0)