diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-18 09:17:54 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-18 09:17:54 -0300 |
| commit | 56137d58ff7abe8cb22ee3469366e08888c84f28 (patch) | |
| tree | 6769e3c2403a69cf3f0d6dbf6fb4acb7442367e0 /lstate.h | |
| parent | 9aec500a2691d2b13c307d143868c8a4fab33220 (diff) | |
| download | lua-56137d58ff7abe8cb22ee3469366e08888c84f28.tar.gz lua-56137d58ff7abe8cb22ee3469366e08888c84f28.tar.bz2 lua-56137d58ff7abe8cb22ee3469366e08888c84f28.zip | |
added check for conversion 'obj2gco' (and corrections for small
problems detected by this check)
Diffstat (limited to 'lstate.h')
| -rw-r--r-- | lstate.h | 16 |
1 files changed, 12 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.h,v 2.109 2014/07/17 17:09:50 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.110 2014/07/17 17:27:49 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -170,7 +170,7 @@ struct lua_State { | |||
| 170 | 170 | ||
| 171 | 171 | ||
| 172 | /* | 172 | /* |
| 173 | ** Union of all collectable objects | 173 | ** Union of all collectable objects (only for conversions) |
| 174 | */ | 174 | */ |
| 175 | union GCUnion { | 175 | union GCUnion { |
| 176 | GCObject gc; /* common header */ | 176 | GCObject gc; /* common header */ |
| @@ -200,8 +200,16 @@ union GCUnion { | |||
| 200 | #define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th)) | 200 | #define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th)) |
| 201 | 201 | ||
| 202 | 202 | ||
| 203 | /* macro to convert any Lua object into a GCObject */ | 203 | /* macro to convert a Lua object into a GCObject */ |
| 204 | #define obj2gco(v) (&(cast_u(v)->gc)) | 204 | #define obj2gco(v) \ |
| 205 | check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc))) | ||
| 206 | |||
| 207 | /* | ||
| 208 | ** macro to convert a TString into a GCObject. | ||
| 209 | ** (TString is a union, and therefore needs an access slightly different | ||
| 210 | ** from the other objects.) | ||
| 211 | */ | ||
| 212 | #define ts2gco(v) (obj2gco(&(v)->tsv)) | ||
| 205 | 213 | ||
| 206 | 214 | ||
| 207 | /* actual number of total bytes allocated */ | 215 | /* actual number of total bytes allocated */ |
