diff options
-rw-r--r-- | lfunc.c | 6 | ||||
-rw-r--r-- | lstate.h | 5 |
2 files changed, 5 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 2.11 2005/05/05 20:47:02 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp roberto $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -55,7 +55,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { | |||
55 | GCObject **pp = &L->openupval; | 55 | GCObject **pp = &L->openupval; |
56 | UpVal *p; | 56 | UpVal *p; |
57 | UpVal *uv; | 57 | UpVal *uv; |
58 | while ((p = ngcotouv(*pp)) != NULL && p->v >= level) { | 58 | while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { |
59 | lua_assert(p->v != &p->u.value); | 59 | lua_assert(p->v != &p->u.value); |
60 | if (p->v == level) { /* found a corresponding upvalue? */ | 60 | if (p->v == level) { /* found a corresponding upvalue? */ |
61 | if (isdead(g, obj2gco(p))) /* is it dead? */ | 61 | if (isdead(g, obj2gco(p))) /* is it dead? */ |
@@ -96,7 +96,7 @@ void luaF_freeupval (lua_State *L, UpVal *uv) { | |||
96 | void luaF_close (lua_State *L, StkId level) { | 96 | void luaF_close (lua_State *L, StkId level) { |
97 | UpVal *uv; | 97 | UpVal *uv; |
98 | global_State *g = G(L); | 98 | global_State *g = G(L); |
99 | while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { | 99 | while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { |
100 | GCObject *o = obj2gco(uv); | 100 | GCObject *o = obj2gco(uv); |
101 | lua_assert(!isblack(o) && uv->v != &uv->u.value); | 101 | lua_assert(!isblack(o) && uv->v != &uv->u.value); |
102 | L->openupval = uv->next; /* remove from `open' list */ | 102 | L->openupval = uv->next; /* remove from `open' list */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 2.26 2006/08/15 19:59:20 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.27 2006/09/19 13:57:50 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 | */ |
@@ -156,8 +156,7 @@ union GCObject { | |||
156 | #define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) | 156 | #define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) |
157 | #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) | 157 | #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) |
158 | #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) | 158 | #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) |
159 | #define ngcotouv(o) \ | 159 | #define ngcotouv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) |
160 | check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) | ||
161 | #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) | 160 | #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) |
162 | 161 | ||
163 | /* macro to convert any Lua object into a GCObject */ | 162 | /* macro to convert any Lua object into a GCObject */ |