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
This commit is contained in:
Roberto Ierusalimschy
2010-04-08 14:16:46 -03:00
parent 28aa733c15
commit 055104f5b6
4 changed files with 13 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lstate.c,v 2.76 2010/03/29 17:43:14 roberto Exp roberto $
** $Id: lstate.c,v 2.77 2010/04/05 16:35:37 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -34,6 +34,9 @@
#endif
#define MEMERRMSG "not enough memory"
/*
** thread state + extra space
*/
@@ -157,7 +160,9 @@ static void f_luaopen (lua_State *L, void *ud) {
luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
luaT_init(L);
luaX_init(L);
luaS_fix(luaS_newliteral(L, MEMERRMSG));
/* pre-create memory-error message */
g->memerrmsg = luaS_newliteral(L, MEMERRMSG);
luaS_fix(g->memerrmsg); /* it should never be collected */
g->GCthreshold = 4*g->totalbytes;
}