diff options
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 1.129 2003/12/01 16:33:30 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.130 2003/12/01 18:22:56 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 | */ |
@@ -74,7 +74,13 @@ static void freestack (lua_State *L, lua_State *L1) { | |||
74 | ** open parts that may cause memory-allocation errors | 74 | ** open parts that may cause memory-allocation errors |
75 | */ | 75 | */ |
76 | static void f_luaopen (lua_State *L, void *ud) { | 76 | static void f_luaopen (lua_State *L, void *ud) { |
77 | Udata *u; /* head of udata list */ | ||
77 | UNUSED(ud); | 78 | UNUSED(ud); |
79 | u = cast(Udata *, luaM_malloc(L, sizeudata(0))); | ||
80 | u->uv.len = 0; | ||
81 | u->uv.metatable = NULL; | ||
82 | G(L)->firstudata = valtogco(u); | ||
83 | luaC_link(L, valtogco(u), LUA_TUSERDATA); | ||
78 | stack_init(L, L); /* init stack */ | 84 | stack_init(L, L); /* init stack */ |
79 | sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */ | 85 | sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */ |
80 | sethvalue(registry(L), luaH_new(L, 4, 4)); /* registry */ | 86 | sethvalue(registry(L), luaH_new(L, 4, 4)); /* registry */ |
@@ -110,7 +116,6 @@ static void close_state (lua_State *L) { | |||
110 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | 116 | luaF_close(L, L->stack); /* close all upvalues for this thread */ |
111 | luaC_sweepall(L); /* collect all elements */ | 117 | luaC_sweepall(L); /* collect all elements */ |
112 | lua_assert(g->rootgc == NULL); | 118 | lua_assert(g->rootgc == NULL); |
113 | lua_assert(g->rootudata == NULL); | ||
114 | luaS_freeall(L); | 119 | luaS_freeall(L); |
115 | luaZ_freebuffer(L, &g->buff); | 120 | luaZ_freebuffer(L, &g->buff); |
116 | freestack(L, L); | 121 | freestack(L, L); |
@@ -162,7 +167,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
162 | g->panic = NULL; | 167 | g->panic = NULL; |
163 | g->gcstate = 0; | 168 | g->gcstate = 0; |
164 | g->rootgc = NULL; | 169 | g->rootgc = NULL; |
165 | g->rootudata = NULL; | 170 | g->firstudata = NULL; |
166 | g->gray = NULL; | 171 | g->gray = NULL; |
167 | g->weak = NULL; | 172 | g->weak = NULL; |
168 | g->tmudata = NULL; | 173 | g->tmudata = NULL; |