aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lstate.c b/lstate.c
index 0b9bb671..36535fcb 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 2.56 2009/06/18 18:59:18 roberto Exp roberto $ 2** $Id: lstate.c,v 2.57 2009/07/15 17:26:14 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*/
@@ -91,6 +91,16 @@ static void freestack (lua_State *L) {
91} 91}
92 92
93 93
94static void init_registry (lua_State *L) {
95 Table *registry = luaH_new(L);
96 TValue mt;
97 sethvalue(L, registry(L), registry);
98 luaH_resize(L, registry, LUA_RIDX_LAST, 0);
99 setthvalue(L, &mt, L);
100 setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt);
101}
102
103
94/* 104/*
95** open parts that may cause memory-allocation errors 105** open parts that may cause memory-allocation errors
96*/ 106*/
@@ -99,7 +109,7 @@ static void f_luaopen (lua_State *L, void *ud) {
99 UNUSED(ud); 109 UNUSED(ud);
100 stack_init(L, L); /* init stack */ 110 stack_init(L, L); /* init stack */
101 sethvalue(L, gt(L), luaH_new(L)); /* table of globals */ 111 sethvalue(L, gt(L), luaH_new(L)); /* table of globals */
102 sethvalue(L, registry(L), luaH_new(L)); /* registry */ 112 init_registry(L);
103 luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ 113 luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
104 luaT_init(L); 114 luaT_init(L);
105 luaX_init(L); 115 luaX_init(L);