diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-01 17:48:12 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-01 17:48:12 -0300 |
commit | 751cd867d3e0338279fa6f3390c8b7ddc0108659 (patch) | |
tree | 726f6f3cd49109382b2c0d7ee6a1e0fea740afbd /lstate.c | |
parent | b36b2a061c88be22e36900146cbcad39bab07f5d (diff) | |
download | lua-751cd867d3e0338279fa6f3390c8b7ddc0108659.tar.gz lua-751cd867d3e0338279fa6f3390c8b7ddc0108659.tar.bz2 lua-751cd867d3e0338279fa6f3390c8b7ddc0108659.zip |
new way to handle errors
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 1.90 2002/04/22 14:40:23 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.91 2002/04/23 15:04:39 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 | */ |
@@ -57,6 +57,7 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
57 | UNUSED(ud); | 57 | UNUSED(ud); |
58 | /* create a new global state */ | 58 | /* create a new global state */ |
59 | L->l_G = luaM_new(L, global_State); | 59 | L->l_G = luaM_new(L, global_State); |
60 | G(L)->GCthreshold = 0; /* mark it as unfinished state */ | ||
60 | G(L)->strt.size = 0; | 61 | G(L)->strt.size = 0; |
61 | G(L)->strt.nuse = 0; | 62 | G(L)->strt.nuse = 0; |
62 | G(L)->strt.hash = NULL; | 63 | G(L)->strt.hash = NULL; |
@@ -83,6 +84,7 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
83 | luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ | 84 | luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ |
84 | luaT_init(L); | 85 | luaT_init(L); |
85 | luaX_init(L); | 86 | luaX_init(L); |
87 | luaS_fix(luaS_newliteral(L, MEMERRMSG)); | ||
86 | G(L)->GCthreshold = 4*G(L)->nblocks; | 88 | G(L)->GCthreshold = 4*G(L)->nblocks; |
87 | } | 89 | } |
88 | 90 | ||
@@ -122,12 +124,14 @@ LUA_API lua_State *lua_newthread (lua_State *OL) { | |||
122 | 124 | ||
123 | LUA_API lua_State *lua_open (void) { | 125 | LUA_API lua_State *lua_open (void) { |
124 | lua_State *L; | 126 | lua_State *L; |
127 | TObject dummy; | ||
128 | setnilvalue(&dummy); | ||
125 | L = luaM_new(NULL, lua_State); | 129 | L = luaM_new(NULL, lua_State); |
126 | if (L) { /* allocation OK? */ | 130 | if (L) { /* allocation OK? */ |
127 | preinit_state(L); | 131 | preinit_state(L); |
128 | L->l_G = NULL; | 132 | L->l_G = NULL; |
129 | L->next = L->previous = L; | 133 | L->next = L->previous = L; |
130 | if (luaD_runprotected(L, f_luaopen, &luaO_nilobject, NULL) != 0) { | 134 | if (luaD_runprotected(L, f_luaopen, &dummy) != 0) { |
131 | /* memory allocation error: free partial state */ | 135 | /* memory allocation error: free partial state */ |
132 | close_state(L); | 136 | close_state(L); |
133 | L = NULL; | 137 | L = NULL; |