diff options
Diffstat (limited to 'lstate.c')
| -rw-r--r-- | lstate.c | 25 |
1 files changed, 4 insertions, 21 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 1.60 2001/03/09 18:05:05 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.61 2001/03/26 14:31:49 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 | */ |
| @@ -30,20 +30,6 @@ static void close_state (lua_State *L, lua_State *OL); | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | /* | 32 | /* |
| 33 | ** initialize ref array and registry | ||
| 34 | */ | ||
| 35 | #define INIT_REFSIZE 4 | ||
| 36 | |||
| 37 | static void ref_init (lua_State *L) { | ||
| 38 | G(L)->refArray = luaM_newvector(L, INIT_REFSIZE, struct Ref); | ||
| 39 | G(L)->sizeref = INIT_REFSIZE; | ||
| 40 | sethvalue(&G(L)->refArray[0].o, luaH_new(L, 0)); | ||
| 41 | G(L)->refArray[0].st = LOCK; | ||
| 42 | G(L)->nref = 1; | ||
| 43 | } | ||
| 44 | |||
| 45 | |||
| 46 | /* | ||
| 47 | ** open parts that may cause memory-allocation errors | 33 | ** open parts that may cause memory-allocation errors |
| 48 | */ | 34 | */ |
| 49 | static void f_luaopen (lua_State *L, void *ud) { | 35 | static void f_luaopen (lua_State *L, void *ud) { |
| @@ -74,18 +60,16 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
| 74 | G(L)->TMtable = NULL; | 60 | G(L)->TMtable = NULL; |
| 75 | G(L)->sizeTM = 0; | 61 | G(L)->sizeTM = 0; |
| 76 | G(L)->ntag = 0; | 62 | G(L)->ntag = 0; |
| 77 | G(L)->refArray = NULL; | ||
| 78 | G(L)->nref = 0; | ||
| 79 | G(L)->sizeref = 0; | ||
| 80 | G(L)->refFree = NONEXT; | ||
| 81 | G(L)->nblocks = sizeof(lua_State) + sizeof(global_State); | 63 | G(L)->nblocks = sizeof(lua_State) + sizeof(global_State); |
| 82 | luaD_init(L, so->stacksize); /* init stack */ | 64 | luaD_init(L, so->stacksize); /* init stack */ |
| 83 | L->gt = luaH_new(L, 10); /* table of globals */ | 65 | L->gt = luaH_new(L, 10); /* table of globals */ |
| 84 | G(L)->type2tag = luaH_new(L, 10); | 66 | G(L)->type2tag = luaH_new(L, 10); |
| 67 | G(L)->registry = luaH_new(L, 0); | ||
| 68 | G(L)->weakregistry = luaH_new(L, 0); | ||
| 69 | G(L)->weakregistry->weakmode = LUA_WEAK_VALUE; /* make weakregistry weak */ | ||
| 85 | luaS_init(L); | 70 | luaS_init(L); |
| 86 | luaX_init(L); | 71 | luaX_init(L); |
| 87 | luaT_init(L); | 72 | luaT_init(L); |
| 88 | ref_init(L); | ||
| 89 | G(L)->GCthreshold = 4*G(L)->nblocks; | 73 | G(L)->GCthreshold = 4*G(L)->nblocks; |
| 90 | } | 74 | } |
| 91 | } | 75 | } |
| @@ -133,7 +117,6 @@ static void close_state (lua_State *L, lua_State *OL) { | |||
| 133 | lua_assert(G(L)->roottable == NULL); | 117 | lua_assert(G(L)->roottable == NULL); |
| 134 | luaS_freeall(L); | 118 | luaS_freeall(L); |
| 135 | luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM); | 119 | luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM); |
| 136 | luaM_freearray(L, G(L)->refArray, G(L)->sizeref, struct Ref); | ||
| 137 | luaM_freearray(L, G(L)->Mbuffer, G(L)->Mbuffsize, l_char); | 120 | luaM_freearray(L, G(L)->Mbuffer, G(L)->Mbuffsize, l_char); |
| 138 | luaM_freelem(NULL, L->G, global_State); | 121 | luaM_freelem(NULL, L->G, global_State); |
| 139 | } | 122 | } |
