** free half of the CallInfo structures not in use by a thread, ** keeping the first one. */
| 136 | ** keeping the first one. |
| 137 | */ |
| 138 | void luaE_shrinkCI (lua_State *L) { |
| 139 | CallInfo *ci = L->ci->next; /* first free CallInfo */ |
| 140 | CallInfo *next; |
| 141 | if (ci == NULL) |
| 142 | return; /* no extra elements */ |
| 143 | while ((next = ci->next) != NULL) { /* two extra elements? */ |
| 144 | CallInfo *next2 = next->next; /* next's next */ |
| 145 | ci->next = next2; /* remove next from the list */ |
| 146 | L->nci--; |
| 147 | luaM_free(L, next); /* free next */ |
| 148 | if (next2 == NULL) |
| 149 | break; /* no more elements */ |
| 150 | else { |
| 151 | next2->previous = ci; |
| 152 | ci = next2; /* continue */ |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | |
| 158 | /* |