diff options
| -rw-r--r-- | ldo.c | 6 | ||||
| -rw-r--r-- | lmem.h | 4 | ||||
| -rw-r--r-- | lstate.c | 9 | ||||
| -rw-r--r-- | lstate.h | 3 |
4 files changed, 13 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.81 2010/02/09 11:56:29 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.82 2010/03/26 20:58:11 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -83,8 +83,8 @@ struct lua_longjmp { | |||
| 83 | 83 | ||
| 84 | static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { | 84 | static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { |
| 85 | switch (errcode) { | 85 | switch (errcode) { |
| 86 | case LUA_ERRMEM: { | 86 | case LUA_ERRMEM: { /* memory error? */ |
| 87 | setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); | 87 | setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ |
| 88 | break; | 88 | break; |
| 89 | } | 89 | } |
| 90 | case LUA_ERRERR: { | 90 | case LUA_ERRERR: { |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmem.h,v 1.34 2009/04/17 14:40:13 roberto Exp roberto $ | 2 | ** $Id: lmem.h,v 1.35 2009/12/16 16:42:58 roberto Exp roberto $ |
| 3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -13,8 +13,6 @@ | |||
| 13 | #include "llimits.h" | 13 | #include "llimits.h" |
| 14 | #include "lua.h" | 14 | #include "lua.h" |
| 15 | 15 | ||
| 16 | #define MEMERRMSG "not enough memory" | ||
| 17 | |||
| 18 | 16 | ||
| 19 | #define luaM_reallocv(L,b,on,n,e) \ | 17 | #define luaM_reallocv(L,b,on,n,e) \ |
| 20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ | 18 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ |
| @@ -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 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.h,v 2.59 2010/03/29 17:43:14 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.60 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 | */ |
| @@ -142,6 +142,7 @@ typedef struct global_State { | |||
| 142 | lua_CFunction panic; /* to be called in unprotected errors */ | 142 | lua_CFunction panic; /* to be called in unprotected errors */ |
| 143 | struct lua_State *mainthread; | 143 | struct lua_State *mainthread; |
| 144 | const lua_Number *version; /* pointer to version number */ | 144 | const lua_Number *version; /* pointer to version number */ |
| 145 | TString *memerrmsg; /* memory-error message */ | ||
| 145 | TString *tmname[TM_N]; /* array with tag-method names */ | 146 | TString *tmname[TM_N]; /* array with tag-method names */ |
| 146 | struct Table *mt[NUM_TAGS]; /* metatables for basic types */ | 147 | struct Table *mt[NUM_TAGS]; /* metatables for basic types */ |
| 147 | } global_State; | 148 | } global_State; |
