From 055104f5b6a0264974c5d9f2a55499420a1c9c2a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 8 Apr 2010 14:16:46 -0300 Subject: 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 --- lstate.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 51272622..0d88c960 100644 --- a/lstate.c +++ b/lstate.c @@ -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; } -- cgit v1.2.3-55-g6feb