** free half of the CallInfo structures not in use by a thread */
| 189 | ** free half of the CallInfo structures not in use by a thread |
| 190 | */ |
| 191 | void luaE_shrinkCI (lua_State *L) { |
| 192 | CallInfo *ci = L->ci; |
| 193 | CallInfo *next2; /* next's next */ |
| 194 | L->nCcalls += L->nci; /* add removed elements back to 'nCcalls' */ |
| 195 | /* while there are two nexts */ |
| 196 | while (ci->next != NULL && (next2 = ci->next->next) != NULL) { |
| 197 | luaM_free(L, ci->next); /* free next */ |
| 198 | L->nci--; |
| 199 | ci->next = next2; /* remove 'next' from the list */ |
| 200 | next2->previous = ci; |
| 201 | ci = next2; /* keep next's next */ |
| 202 | } |
| 203 | L->nCcalls -= L->nci; /* adjust result */ |
| 204 | } |
| 205 | |
| 206 | |
| 207 | static void stack_init (lua_State *L1, lua_State *L) { |