diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/keeper.c | 4 | ||||
| -rw-r--r-- | src/linda.c | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/keeper.c b/src/keeper.c index a1505b7..1522718 100644 --- a/src/keeper.c +++ b/src/keeper.c | |||
| @@ -810,7 +810,9 @@ int keeper_call( Universe* U, lua_State* K, keeper_api_t func_, lua_State* L, vo | |||
| 810 | int const Ktos = lua_gettop( K); | 810 | int const Ktos = lua_gettop( K); |
| 811 | int retvals = -1; | 811 | int retvals = -1; |
| 812 | 812 | ||
| 813 | STACK_GROW( K, 2); | 813 | // if we didn't do anything wrong, the keeper stack should be clean |
| 814 | ASSERT_L(Ktos == 0); | ||
| 815 | STACK_GROW(K, 2); | ||
| 814 | 816 | ||
| 815 | PUSH_KEEPER_FUNC( K, func_); | 817 | PUSH_KEEPER_FUNC( K, func_); |
| 816 | 818 | ||
diff --git a/src/linda.c b/src/linda.c index 2128520..d92f5f2 100644 --- a/src/linda.c +++ b/src/linda.c | |||
| @@ -90,12 +90,16 @@ LUAG_FUNC( linda_protected_call) | |||
| 90 | Keeper* K = keeper_acquire( linda->U->keepers, LINDA_KEEPER_HASHSEED(linda)); | 90 | Keeper* K = keeper_acquire( linda->U->keepers, LINDA_KEEPER_HASHSEED(linda)); |
| 91 | lua_State* KL = K ? K->L : NULL; // need to do this for 'STACK_CHECK' | 91 | lua_State* KL = K ? K->L : NULL; // need to do this for 'STACK_CHECK' |
| 92 | if( KL == NULL) return 0; | 92 | if( KL == NULL) return 0; |
| 93 | // if we didn't do anything wrong, the keeper stack should be clean | ||
| 94 | ASSERT_L(lua_gettop(KL) == 0); | ||
| 93 | 95 | ||
| 94 | // retrieve the actual function to be called and move it before the arguments | 96 | // retrieve the actual function to be called and move it before the arguments |
| 95 | lua_pushvalue( L, lua_upvalueindex( 1)); | 97 | lua_pushvalue( L, lua_upvalueindex( 1)); |
| 96 | lua_insert( L, 1); | 98 | lua_insert( L, 1); |
| 97 | // do a protected call | 99 | // do a protected call |
| 98 | rc = lua_pcall( L, lua_gettop( L) - 1, LUA_MULTRET, 0); | 100 | rc = lua_pcall( L, lua_gettop( L) - 1, LUA_MULTRET, 0); |
| 101 | // whatever happens, the keeper state stack must be empty when we are done | ||
| 102 | lua_settop(KL, 0); | ||
| 99 | 103 | ||
| 100 | // release the keeper | 104 | // release the keeper |
| 101 | keeper_release( K); | 105 | keeper_release( K); |
