diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-08 14:16:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-08 14:16:46 -0300 |
commit | 055104f5b6a0264974c5d9f2a55499420a1c9c2a (patch) | |
tree | 0326d843489810878c8e5c80c4c9f6a29261fbce /lstate.c | |
parent | 28aa733c15e814eb5708c58063ea1fb636ec7876 (diff) | |
download | lua-055104f5b6a0264974c5d9f2a55499420a1c9c2a.tar.gz lua-055104f5b6a0264974c5d9f2a55499420a1c9c2a.tar.bz2 lua-055104f5b6a0264974c5d9f2a55499420a1c9c2a.zip |
keep memory-error message in the global state, so that its use
does not depend on Lua internalizing strings to avoid a string
creation on memory errors
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.76 2010/03/29 17:43:14 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.77 2010/04/05 16:35:37 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 | */ |
@@ -34,6 +34,9 @@ | |||
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | 36 | ||
37 | #define MEMERRMSG "not enough memory" | ||
38 | |||
39 | |||
37 | /* | 40 | /* |
38 | ** thread state + extra space | 41 | ** thread state + extra space |
39 | */ | 42 | */ |
@@ -157,7 +160,9 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
157 | luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ | 160 | luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ |
158 | luaT_init(L); | 161 | luaT_init(L); |
159 | luaX_init(L); | 162 | luaX_init(L); |
160 | luaS_fix(luaS_newliteral(L, MEMERRMSG)); | 163 | /* pre-create memory-error message */ |
164 | g->memerrmsg = luaS_newliteral(L, MEMERRMSG); | ||
165 | luaS_fix(g->memerrmsg); /* it should never be collected */ | ||
161 | g->GCthreshold = 4*g->totalbytes; | 166 | g->GCthreshold = 4*g->totalbytes; |
162 | } | 167 | } |
163 | 168 | ||