diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-07 15:15:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-07 15:15:10 -0300 |
commit | c16a35d6696ac995ef6c7b60f251f6821811f50f (patch) | |
tree | 8a25bd8597f46fe7db32cce9efa6668f6b950edc /lapi.c | |
parent | 8f837e83b20f3c409ba187765c2bf5aefc111923 (diff) | |
download | lua-c16a35d6696ac995ef6c7b60f251f6821811f50f.tar.gz lua-c16a35d6696ac995ef6c7b60f251f6821811f50f.tar.bz2 lua-c16a35d6696ac995ef6c7b60f251f6821811f50f.zip |
`lua_stackspace' replaced by `lua_checkstack'
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.174 2002/02/14 21:46:13 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.175 2002/03/04 21:29:41 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 | */ |
@@ -80,8 +80,18 @@ void luaA_pushobject (lua_State *L, const TObject *o) { | |||
80 | incr_top(L); | 80 | incr_top(L); |
81 | } | 81 | } |
82 | 82 | ||
83 | LUA_API int lua_stackspace (lua_State *L) { | 83 | |
84 | return (L->stack_last - L->top); | 84 | LUA_API int lua_checkstack (lua_State *L, int size) { |
85 | int res; | ||
86 | lua_lock(L); | ||
87 | if ((L->top - L->stack) + size >= LUA_MAXSTACK) | ||
88 | res = 0; /* stack overflow */ | ||
89 | luaD_checkstack(L, size); | ||
90 | if (L->ci->top < L->top + size) | ||
91 | L->ci->top = L->top + size; | ||
92 | res = 1; | ||
93 | lua_unlock(L); | ||
94 | return res; | ||
85 | } | 95 | } |
86 | 96 | ||
87 | 97 | ||
@@ -667,8 +677,7 @@ LUA_API int lua_pushupvalues (lua_State *L) { | |||
667 | func = (L->ci->base - 1); | 677 | func = (L->ci->base - 1); |
668 | api_check(L, iscfunction(func)); | 678 | api_check(L, iscfunction(func)); |
669 | n = clvalue(func)->c.nupvalues; | 679 | n = clvalue(func)->c.nupvalues; |
670 | if (LUA_MINSTACK+n > lua_stackspace(L)) | 680 | luaD_checkstack(L, n + LUA_MINSTACK); |
671 | luaD_error(L, "stack overflow"); | ||
672 | for (i=0; i<n; i++) { | 681 | for (i=0; i<n; i++) { |
673 | setobj(L->top, &clvalue(func)->c.upvalue[i]); | 682 | setobj(L->top, &clvalue(func)->c.upvalue[i]); |
674 | L->top++; | 683 | L->top++; |