diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-15 16:31:22 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-15 16:31:22 -0300 |
| commit | b95e46621873cfb460e1d11dcd153914d5d69f86 (patch) | |
| tree | aeb1db66a8254b5f997bcfd0a8ac606eea2f621c /ltm.c | |
| parent | d406d3d05ffe8bc01d6416437963ce092cfc9772 (diff) | |
| download | lua-b95e46621873cfb460e1d11dcd153914d5d69f86.tar.gz lua-b95e46621873cfb460e1d11dcd153914d5d69f86.tar.bz2 lua-b95e46621873cfb460e1d11dcd153914d5d69f86.zip | |
new field 'nilvalue' in struct 'global_State' to avoid the use of
addresses of static variables
Diffstat (limited to 'ltm.c')
| -rw-r--r-- | ltm.c | 5 |
1 files changed, 2 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 2.68 2018/06/01 17:40:38 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.69 2018/06/08 19:06:59 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -69,7 +69,6 @@ const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { | |||
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { | 71 | const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { |
| 72 | static const TValue nilobject = {NILCONSTANT}; | ||
| 73 | Table *mt; | 72 | Table *mt; |
| 74 | switch (ttype(o)) { | 73 | switch (ttype(o)) { |
| 75 | case LUA_TTABLE: | 74 | case LUA_TTABLE: |
| @@ -81,7 +80,7 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { | |||
| 81 | default: | 80 | default: |
| 82 | mt = G(L)->mt[ttype(o)]; | 81 | mt = G(L)->mt[ttype(o)]; |
| 83 | } | 82 | } |
| 84 | return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &nilobject); | 83 | return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &G(L)->nilvalue); |
| 85 | } | 84 | } |
| 86 | 85 | ||
| 87 | 86 | ||
