aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-04-08 14:16:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-04-08 14:16:46 -0300
commit055104f5b6a0264974c5d9f2a55499420a1c9c2a (patch)
tree0326d843489810878c8e5c80c4c9f6a29261fbce /lstate.c
parent28aa733c15e814eb5708c58063ea1fb636ec7876 (diff)
downloadlua-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.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lstate.c b/lstate.c
index 51272622..0d88c960 100644
--- a/lstate.c
+++ b/lstate.c
@@ -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