diff options
-rw-r--r-- | lapi.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.177 2002/03/18 18:18:35 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.178 2002/03/18 20:11:52 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -35,7 +35,7 @@ const char lua_ident[] = | |||
35 | 35 | ||
36 | #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base)) | 36 | #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base)) |
37 | 37 | ||
38 | #define api_incr_top(L) (api_check(L, L->top+1<L->stack_last), L->top++) | 38 | #define api_incr_top(L) (api_check(L, L->top<L->ci->top), L->top++) |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
@@ -85,12 +85,14 @@ void luaA_pushobject (lua_State *L, const TObject *o) { | |||
85 | LUA_API int lua_checkstack (lua_State *L, int size) { | 85 | LUA_API int lua_checkstack (lua_State *L, int size) { |
86 | int res; | 86 | int res; |
87 | lua_lock(L); | 87 | lua_lock(L); |
88 | if ((L->top - L->stack) + size >= LUA_MAXSTACK) | 88 | if ((L->top - L->stack) >= LUA_MAXSTACK - size) |
89 | res = 0; /* stack overflow */ | 89 | res = 0; /* stack overflow */ |
90 | luaD_checkstack(L, size); | 90 | else { |
91 | if (L->ci->top < L->top + size) | 91 | luaD_checkstack(L, size); |
92 | L->ci->top = L->top + size; | 92 | if (L->ci->top < L->top + size) |
93 | res = 1; | 93 | L->ci->top = L->top + size; |
94 | res = 1; | ||
95 | } | ||
94 | lua_unlock(L); | 96 | lua_unlock(L); |
95 | return res; | 97 | return res; |
96 | } | 98 | } |