summaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-09-17 12:40:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-09-17 12:40:06 -0300
commit4c6dfc342b026a51bfe3e2d56b1032fb670a2577 (patch)
treefa73b9a56acbd6b5f75e13e9bc15c0f2a5eef8d4 /lstate.c
parent686e57cf9c61070ff961407e3304071e171542f4 (diff)
downloadlua-4c6dfc342b026a51bfe3e2d56b1032fb670a2577.tar.gz
lua-4c6dfc342b026a51bfe3e2d56b1032fb670a2577.tar.bz2
lua-4c6dfc342b026a51bfe3e2d56b1032fb670a2577.zip
CallInfo lists shrinks together with their associated stacks
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/lstate.c b/lstate.c
index 0c3eb8f1..eab904fc 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 2.113 2013/09/11 14:09:55 roberto Exp roberto $ 2** $Id: lstate.c,v 2.114 2013/09/13 16:21:52 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -119,6 +119,9 @@ CallInfo *luaE_extendCI (lua_State *L) {
119} 119}
120 120
121 121
122/*
123** free all CallInfo structures not in use by a thread
124*/
122void luaE_freeCI (lua_State *L) { 125void luaE_freeCI (lua_State *L) {
123 CallInfo *ci = L->ci; 126 CallInfo *ci = L->ci;
124 CallInfo *next = ci->next; 127 CallInfo *next = ci->next;
@@ -130,6 +133,22 @@ void luaE_freeCI (lua_State *L) {
130} 133}
131 134
132 135
136/*
137** free half of the CallInfo structures not in use by a thread
138*/
139void luaE_shrinkCI (lua_State *L) {
140 CallInfo *ci = L->ci;
141 while (ci->next != NULL) { /* while there is 'next' */
142 CallInfo *next2 = ci->next->next; /* next's next */
143 if (next2 == NULL) break;
144 luaM_free(L, ci->next); /* remove next */
145 ci->next = next2; /* remove 'next' from the list */
146 next2->previous = ci;
147 ci = next2;
148 }
149}
150
151
133static void stack_init (lua_State *L1, lua_State *L) { 152static void stack_init (lua_State *L1, lua_State *L) {
134 int i; CallInfo *ci; 153 int i; CallInfo *ci;
135 /* initialize stack array */ 154 /* initialize stack array */