diff options
Diffstat (limited to 'lstring.c')
-rw-r--r-- | lstring.c | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 1.5 1997/11/19 17:29:23 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 1.6 1997/11/21 19:00:46 roberto Exp roberto $ |
3 | ** String table (keep all strings handled by Lua) | 3 | ** String table (keep all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -195,6 +195,44 @@ TaggedString *luaS_collector (void) | |||
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | TaggedString *luaS_collectudata (void) | ||
199 | { | ||
200 | TaggedString *frees = NULL; | ||
201 | int i; | ||
202 | L->rootglobal.next = NULL; /* empty list of globals */ | ||
203 | for (i=0; i<NUM_HASHS; i++) { | ||
204 | stringtable *tb = &L->string_root[i]; | ||
205 | int j; | ||
206 | for (j=0; j<tb->size; j++) { | ||
207 | TaggedString *t = tb->hash[j]; | ||
208 | if (t == NULL || t == &EMPTY || t->constindex != -1) | ||
209 | continue; /* get only user datas */ | ||
210 | t->head.next = (GCnode *)frees; | ||
211 | frees = t; | ||
212 | tb->hash[j] = &EMPTY; | ||
213 | } | ||
214 | } | ||
215 | return frees; | ||
216 | } | ||
217 | |||
218 | |||
219 | void luaS_freeall (void) | ||
220 | { | ||
221 | int i; | ||
222 | for (i=0; i<NUM_HASHS; i++) { | ||
223 | stringtable *tb = &L->string_root[i]; | ||
224 | int j; | ||
225 | for (j=0; j<tb->size; j++) { | ||
226 | TaggedString *t = tb->hash[j]; | ||
227 | if (t == &EMPTY) continue; | ||
228 | luaM_free(t); | ||
229 | } | ||
230 | luaM_free(tb->hash); | ||
231 | } | ||
232 | luaM_free(L->string_root); | ||
233 | } | ||
234 | |||
235 | |||
198 | void luaS_rawsetglobal (TaggedString *ts, TObject *newval) | 236 | void luaS_rawsetglobal (TaggedString *ts, TObject *newval) |
199 | { | 237 | { |
200 | ts->u.globalval = *newval; | 238 | ts->u.globalval = *newval; |