From 3393fd7f257397199c6ecd143f956a19ee4a0cf7 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 1 Dec 1997 18:31:25 -0200 Subject: first version of "lua_close" --- lstring.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'lstring.c') diff --git a/lstring.c b/lstring.c index b4e435df..6f3ba519 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 1.5 1997/11/19 17:29:23 roberto Exp roberto $ +** $Id: lstring.c,v 1.6 1997/11/21 19:00:46 roberto Exp roberto $ ** String table (keep all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -195,6 +195,44 @@ TaggedString *luaS_collector (void) } +TaggedString *luaS_collectudata (void) +{ + TaggedString *frees = NULL; + int i; + L->rootglobal.next = NULL; /* empty list of globals */ + for (i=0; istring_root[i]; + int j; + for (j=0; jsize; j++) { + TaggedString *t = tb->hash[j]; + if (t == NULL || t == &EMPTY || t->constindex != -1) + continue; /* get only user datas */ + t->head.next = (GCnode *)frees; + frees = t; + tb->hash[j] = ∅ + } + } + return frees; +} + + +void luaS_freeall (void) +{ + int i; + for (i=0; istring_root[i]; + int j; + for (j=0; jsize; j++) { + TaggedString *t = tb->hash[j]; + if (t == &EMPTY) continue; + luaM_free(t); + } + luaM_free(tb->hash); + } + luaM_free(L->string_root); +} + + void luaS_rawsetglobal (TaggedString *ts, TObject *newval) { ts->u.globalval = *newval; -- cgit v1.2.3-55-g6feb