diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-21 12:16:52 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-21 12:16:52 -0200 |
| commit | 1648674653bd33775a6ab31539f9d9490b3282ae (patch) | |
| tree | cbc2562e87377b8674d48fb47780e5e61b3ea31f | |
| parent | d404f0c276e4a81d044be8c7647635acbe13ff06 (diff) | |
| download | lua-1648674653bd33775a6ab31539f9d9490b3282ae.tar.gz lua-1648674653bd33775a6ab31539f9d9490b3282ae.tar.bz2 lua-1648674653bd33775a6ab31539f9d9490b3282ae.zip | |
must check GC every time it can create new objects
| -rw-r--r-- | lapi.c | 12 |
1 files changed, 10 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.219 2002/11/14 11:51:50 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.220 2002/11/14 16:15:53 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 | */ |
| @@ -131,6 +131,7 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { | |||
| 131 | LUA_API lua_State *lua_newthread (lua_State *L) { | 131 | LUA_API lua_State *lua_newthread (lua_State *L) { |
| 132 | lua_State *L1; | 132 | lua_State *L1; |
| 133 | lua_lock(L); | 133 | lua_lock(L); |
| 134 | luaC_checkGC(L); | ||
| 134 | L1 = luaE_newthread(L); | 135 | L1 = luaE_newthread(L); |
| 135 | setthvalue(L->top, L1); | 136 | setthvalue(L->top, L1); |
| 136 | api_incr_top(L); | 137 | api_incr_top(L); |
| @@ -309,6 +310,7 @@ LUA_API const char *lua_tostring (lua_State *L, int index) { | |||
| 309 | const char *s; | 310 | const char *s; |
| 310 | lua_lock(L); /* `luaV_tostring' may create a new string */ | 311 | lua_lock(L); /* `luaV_tostring' may create a new string */ |
| 311 | s = (luaV_tostring(L, o) ? svalue(o) : NULL); | 312 | s = (luaV_tostring(L, o) ? svalue(o) : NULL); |
| 313 | luaC_checkGC(L); | ||
| 312 | lua_unlock(L); | 314 | lua_unlock(L); |
| 313 | return s; | 315 | return s; |
| 314 | } | 316 | } |
| @@ -394,6 +396,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { | |||
| 394 | 396 | ||
| 395 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { | 397 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { |
| 396 | lua_lock(L); | 398 | lua_lock(L); |
| 399 | luaC_checkGC(L); | ||
| 397 | setsvalue2s(L->top, luaS_newlstr(L, s, len)); | 400 | setsvalue2s(L->top, luaS_newlstr(L, s, len)); |
| 398 | api_incr_top(L); | 401 | api_incr_top(L); |
| 399 | lua_unlock(L); | 402 | lua_unlock(L); |
| @@ -412,6 +415,7 @@ LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, | |||
| 412 | va_list argp) { | 415 | va_list argp) { |
| 413 | const char *ret; | 416 | const char *ret; |
| 414 | lua_lock(L); | 417 | lua_lock(L); |
| 418 | luaC_checkGC(L); | ||
| 415 | ret = luaO_pushvfstring(L, fmt, argp); | 419 | ret = luaO_pushvfstring(L, fmt, argp); |
| 416 | lua_unlock(L); | 420 | lua_unlock(L); |
| 417 | return ret; | 421 | return ret; |
| @@ -422,6 +426,7 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { | |||
| 422 | const char *ret; | 426 | const char *ret; |
| 423 | va_list argp; | 427 | va_list argp; |
| 424 | lua_lock(L); | 428 | lua_lock(L); |
| 429 | luaC_checkGC(L); | ||
| 425 | va_start(argp, fmt); | 430 | va_start(argp, fmt); |
| 426 | ret = luaO_pushvfstring(L, fmt, argp); | 431 | ret = luaO_pushvfstring(L, fmt, argp); |
| 427 | va_end(argp); | 432 | va_end(argp); |
| @@ -433,6 +438,7 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { | |||
| 433 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | 438 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { |
| 434 | Closure *cl; | 439 | Closure *cl; |
| 435 | lua_lock(L); | 440 | lua_lock(L); |
| 441 | luaC_checkGC(L); | ||
| 436 | api_checknelems(L, n); | 442 | api_checknelems(L, n); |
| 437 | cl = luaF_newCclosure(L, n); | 443 | cl = luaF_newCclosure(L, n); |
| 438 | cl->c.f = fn; | 444 | cl->c.f = fn; |
| @@ -499,6 +505,7 @@ LUA_API void lua_rawgeti (lua_State *L, int index, int n) { | |||
| 499 | 505 | ||
| 500 | LUA_API void lua_newtable (lua_State *L) { | 506 | LUA_API void lua_newtable (lua_State *L) { |
| 501 | lua_lock(L); | 507 | lua_lock(L); |
| 508 | luaC_checkGC(L); | ||
| 502 | sethvalue(L->top, luaH_new(L, 0, 0)); | 509 | sethvalue(L->top, luaH_new(L, 0, 0)); |
| 503 | api_incr_top(L); | 510 | api_incr_top(L); |
| 504 | lua_unlock(L); | 511 | lua_unlock(L); |
| @@ -753,11 +760,11 @@ LUA_API int lua_next (lua_State *L, int index) { | |||
| 753 | 760 | ||
| 754 | LUA_API void lua_concat (lua_State *L, int n) { | 761 | LUA_API void lua_concat (lua_State *L, int n) { |
| 755 | lua_lock(L); | 762 | lua_lock(L); |
| 763 | luaC_checkGC(L); | ||
| 756 | api_checknelems(L, n); | 764 | api_checknelems(L, n); |
| 757 | if (n >= 2) { | 765 | if (n >= 2) { |
| 758 | luaV_concat(L, n, L->top - L->ci->base - 1); | 766 | luaV_concat(L, n, L->top - L->ci->base - 1); |
| 759 | L->top -= (n-1); | 767 | L->top -= (n-1); |
| 760 | luaC_checkGC(L); | ||
| 761 | } | 768 | } |
| 762 | else if (n == 0) { /* push empty string */ | 769 | else if (n == 0) { /* push empty string */ |
| 763 | setsvalue2s(L->top, luaS_newlstr(L, NULL, 0)); | 770 | setsvalue2s(L->top, luaS_newlstr(L, NULL, 0)); |
| @@ -771,6 +778,7 @@ LUA_API void lua_concat (lua_State *L, int n) { | |||
| 771 | LUA_API void *lua_newuserdata (lua_State *L, size_t size) { | 778 | LUA_API void *lua_newuserdata (lua_State *L, size_t size) { |
| 772 | Udata *u; | 779 | Udata *u; |
| 773 | lua_lock(L); | 780 | lua_lock(L); |
| 781 | luaC_checkGC(L); | ||
| 774 | u = luaS_newudata(L, size); | 782 | u = luaS_newudata(L, size); |
| 775 | setuvalue(L->top, u); | 783 | setuvalue(L->top, u); |
| 776 | api_incr_top(L); | 784 | api_incr_top(L); |
