From 8878554b854009066eeccfe7b17e6e019c69758a Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 3 Dec 2003 10:30:41 -0200
Subject: single list for all collectible objects, with udata separated at the
 end of the list

---
 lstate.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'lstate.c')

diff --git a/lstate.c b/lstate.c
index 40e29c6f..ceaaab81 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.c,v 1.129 2003/12/01 16:33:30 roberto Exp roberto $
+** $Id: lstate.c,v 1.130 2003/12/01 18:22:56 roberto Exp roberto $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -74,7 +74,13 @@ static void freestack (lua_State *L, lua_State *L1) {
 ** open parts that may cause memory-allocation errors
 */
 static void f_luaopen (lua_State *L, void *ud) {
+  Udata *u;  /* head of udata list */
   UNUSED(ud);
+  u = cast(Udata *, luaM_malloc(L, sizeudata(0)));
+  u->uv.len = 0;
+  u->uv.metatable = NULL;
+  G(L)->firstudata = valtogco(u);
+  luaC_link(L, valtogco(u), LUA_TUSERDATA);
   stack_init(L, L);  /* init stack */
   sethvalue(gt(L), luaH_new(L, 0, 4));  /* table of globals */
   sethvalue(registry(L), luaH_new(L, 4, 4));  /* registry */
@@ -110,7 +116,6 @@ static void close_state (lua_State *L) {
   luaF_close(L, L->stack);  /* close all upvalues for this thread */
   luaC_sweepall(L);  /* collect all elements */
   lua_assert(g->rootgc == NULL);
-  lua_assert(g->rootudata == NULL);
   luaS_freeall(L);
   luaZ_freebuffer(L, &g->buff);
   freestack(L, L);
@@ -162,7 +167,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
   g->panic = NULL;
   g->gcstate = 0;
   g->rootgc = NULL;
-  g->rootudata = NULL;
+  g->firstudata = NULL;
   g->gray = NULL;
   g->weak = NULL;
   g->tmudata = NULL;
-- 
cgit v1.2.3-55-g6feb