11/*
2- ** $Id: lapi.c,v 2.257 2015/11/02 18:48:07 roberto Exp $
2+ ** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp $
33** Lua API
44** See Copyright Notice in lua.h
55*/
@@ -378,9 +378,9 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
378378 return NULL ;
379379 }
380380 lua_lock (L ); /* 'luaO_tostring' may create a new string */
381+ luaO_tostring (L , o );
381382 luaC_checkGC (L );
382383 o = index2addr (L , idx ); /* previous call may reallocate the stack */
383- luaO_tostring (L , o );
384384 lua_unlock (L );
385385 }
386386 if (len != NULL )
@@ -479,10 +479,10 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
479479LUA_API const char * lua_pushlstring (lua_State * L , const char * s , size_t len ) {
480480 TString * ts ;
481481 lua_lock (L );
482- luaC_checkGC (L );
483482 ts = (len == 0 ) ? luaS_new (L , "" ) : luaS_newlstr (L , s , len );
484483 setsvalue2s (L , L -> top , ts );
485484 api_incr_top (L );
485+ luaC_checkGC (L );
486486 lua_unlock (L );
487487 return getstr (ts );
488488}
@@ -494,12 +494,12 @@ LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
494494 setnilvalue (L -> top );
495495 else {
496496 TString * ts ;
497- luaC_checkGC (L );
498497 ts = luaS_new (L , s );
499498 setsvalue2s (L , L -> top , ts );
500499 s = getstr (ts ); /* internal copy's address */
501500 }
502501 api_incr_top (L );
502+ luaC_checkGC (L );
503503 lua_unlock (L );
504504 return s ;
505505}
@@ -509,8 +509,8 @@ LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
509509 va_list argp ) {
510510 const char * ret ;
511511 lua_lock (L );
512- luaC_checkGC (L );
513512 ret = luaO_pushvfstring (L , fmt , argp );
513+ luaC_checkGC (L );
514514 lua_unlock (L );
515515 return ret ;
516516}
@@ -520,10 +520,10 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
520520 const char * ret ;
521521 va_list argp ;
522522 lua_lock (L );
523- luaC_checkGC (L );
524523 va_start (argp , fmt );
525524 ret = luaO_pushvfstring (L , fmt , argp );
526525 va_end (argp );
526+ luaC_checkGC (L );
527527 lua_unlock (L );
528528 return ret ;
529529}
@@ -538,7 +538,6 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
538538 CClosure * cl ;
539539 api_checknelems (L , n );
540540 api_check (L , n <= MAXUPVAL , "upvalue index too large" );
541- luaC_checkGC (L );
542541 cl = luaF_newCclosure (L , n );
543542 cl -> f = fn ;
544543 L -> top -= n ;
@@ -549,6 +548,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
549548 setclCvalue (L , L -> top , cl );
550549 }
551550 api_incr_top (L );
551+ luaC_checkGC (L );
552552 lua_unlock (L );
553553}
554554
@@ -585,16 +585,16 @@ LUA_API int lua_pushthread (lua_State *L) {
585585
586586
587587static int auxgetstr (lua_State * L , const TValue * t , const char * k ) {
588- const TValue * aux ;
588+ const TValue * slot ;
589589 TString * str = luaS_new (L , k );
590- if (luaV_fastget (L , t , str , aux , luaH_getstr )) {
591- setobj2s (L , L -> top , aux );
590+ if (luaV_fastget (L , t , str , slot , luaH_getstr )) {
591+ setobj2s (L , L -> top , slot );
592592 api_incr_top (L );
593593 }
594594 else {
595595 setsvalue2s (L , L -> top , str );
596596 api_incr_top (L );
597- luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , aux );
597+ luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , slot );
598598 }
599599 lua_unlock (L );
600600 return ttnov (L -> top - 1 );
@@ -626,17 +626,17 @@ LUA_API int lua_getfield (lua_State *L, int idx, const char *k) {
626626
627627LUA_API int lua_geti (lua_State * L , int idx , lua_Integer n ) {
628628 StkId t ;
629- const TValue * aux ;
629+ const TValue * slot ;
630630 lua_lock (L );
631631 t = index2addr (L , idx );
632- if (luaV_fastget (L , t , n , aux , luaH_getint )) {
633- setobj2s (L , L -> top , aux );
632+ if (luaV_fastget (L , t , n , slot , luaH_getint )) {
633+ setobj2s (L , L -> top , slot );
634634 api_incr_top (L );
635635 }
636636 else {
637637 setivalue (L -> top , n );
638638 api_incr_top (L );
639- luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , aux );
639+ luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , slot );
640640 }
641641 lua_unlock (L );
642642 return ttnov (L -> top - 1 );
@@ -683,12 +683,12 @@ LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) {
683683LUA_API void lua_createtable (lua_State * L , int narray , int nrec ) {
684684 Table * t ;
685685 lua_lock (L );
686- luaC_checkGC (L );
687686 t = luaH_new (L );
688687 sethvalue (L , L -> top , t );
689688 api_incr_top (L );
690689 if (narray > 0 || nrec > 0 )
691690 luaH_resize (L , t , narray , nrec );
691+ luaC_checkGC (L );
692692 lua_unlock (L );
693693}
694694
@@ -740,15 +740,15 @@ LUA_API int lua_getuservalue (lua_State *L, int idx) {
740740** t[k] = value at the top of the stack (where 'k' is a string)
741741*/
742742static void auxsetstr (lua_State * L , const TValue * t , const char * k ) {
743- const TValue * aux ;
743+ const TValue * slot ;
744744 TString * str = luaS_new (L , k );
745745 api_checknelems (L , 1 );
746- if (luaV_fastset (L , t , str , aux , luaH_getstr , L -> top - 1 ))
746+ if (luaV_fastset (L , t , str , slot , luaH_getstr , L -> top - 1 ))
747747 L -> top -- ; /* pop value */
748748 else {
749749 setsvalue2s (L , L -> top , str ); /* push 'str' (to make it a TValue) */
750750 api_incr_top (L );
751- luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , aux );
751+ luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , slot );
752752 L -> top -= 2 ; /* pop value and key */
753753 }
754754 lua_unlock (L ); /* lock done by caller */
@@ -781,16 +781,16 @@ LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
781781
782782LUA_API void lua_seti (lua_State * L , int idx , lua_Integer n ) {
783783 StkId t ;
784- const TValue * aux ;
784+ const TValue * slot ;
785785 lua_lock (L );
786786 api_checknelems (L , 1 );
787787 t = index2addr (L , idx );
788- if (luaV_fastset (L , t , n , aux , luaH_getint , L -> top - 1 ))
788+ if (luaV_fastset (L , t , n , slot , luaH_getint , L -> top - 1 ))
789789 L -> top -- ; /* pop value */
790790 else {
791791 setivalue (L -> top , n );
792792 api_incr_top (L );
793- luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , aux );
793+ luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , slot );
794794 L -> top -= 2 ; /* pop value and key */
795795 }
796796 lua_unlock (L );
@@ -1140,14 +1140,14 @@ LUA_API void lua_concat (lua_State *L, int n) {
11401140 lua_lock (L );
11411141 api_checknelems (L , n );
11421142 if (n >= 2 ) {
1143- luaC_checkGC (L );
11441143 luaV_concat (L , n );
11451144 }
11461145 else if (n == 0 ) { /* push empty string */
11471146 setsvalue2s (L , L -> top , luaS_newlstr (L , "" , 0 ));
11481147 api_incr_top (L );
11491148 }
11501149 /* else n == 1; nothing to do */
1150+ luaC_checkGC (L );
11511151 lua_unlock (L );
11521152}
11531153
@@ -1183,10 +1183,10 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
11831183LUA_API void * lua_newuserdata (lua_State * L , size_t size ) {
11841184 Udata * u ;
11851185 lua_lock (L );
1186- luaC_checkGC (L );
11871186 u = luaS_newudata (L , size );
11881187 setuvalue (L , L -> top , u );
11891188 api_incr_top (L );
1189+ luaC_checkGC (L );
11901190 lua_unlock (L );
11911191 return getudatamem (u );
11921192}
0 commit comments