commit 397905ef8694ec716a51acebc993bb625340d388
parent 435f587ed05e2c4d542e1db9ae9e4efbb7e02305
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 7 Aug 2000 15:38:54 -0300
(much) better handling of memory alloction errors
Diffstat:
4 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/ldo.h b/ldo.h
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.h,v 1.20 2000/04/14 18:12:35 roberto Exp $
+** $Id: ldo.h,v 1.21 2000/06/28 20:21:06 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -25,6 +25,7 @@ void luaD_openstack (lua_State *L, StkId pos);
void luaD_lineHook (lua_State *L, StkId func, int line, lua_Hook linehook);
void luaD_call (lua_State *L, StkId func, int nResults);
void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults);
+void luaD_breakrun (lua_State *L, int errcode);
int luaD_protectedrun (lua_State *L);
void luaD_checkstack (lua_State *L, int n);
diff --git a/lmem.h b/lmem.h
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.h,v 1.13 2000/03/16 20:35:07 roberto Exp roberto $
+** $Id: lmem.h,v 1.14 2000/05/24 13:54:49 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@@ -13,9 +13,6 @@
#include "llimits.h"
#include "lua.h"
-/* memory error message */
-#define memEM "not enough memory"
-
void *luaM_realloc (lua_State *L, void *oldblock, lint32 size);
void *luaM_growaux (lua_State *L, void *block, size_t nelems,
int inc, size_t size, const char *errormsg,
@@ -37,6 +34,7 @@ void *luaM_growaux (lua_State *L, void *block, size_t nelems,
extern unsigned long memdebug_numblocks;
extern unsigned long memdebug_total;
extern unsigned long memdebug_maxmem;
+extern unsigned long memdebug_memlimit;
#endif
diff --git a/lstate.h b/lstate.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.h,v 1.33 2000/05/10 16:33:20 roberto Exp roberto $
+** $Id: lstate.h,v 1.34 2000/05/24 13:54:49 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -19,11 +19,14 @@ typedef TObject *StkId; /* index to stack elements */
/*
-** `jmp_buf' may be an array, so it is better to make sure it has an
-** address (and not that it *is* an address...)
+** chain list of long jumps
*/
struct lua_longjmp {
jmp_buf b;
+ struct lua_longjmp *previous;
+ volatile int status; /* error code */
+ StkId base;
+ int numCblocks;
};
diff --git a/lua.h b/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.54 2000/05/26 19:17:57 roberto Exp roberto $
+** $Id: lua.h,v 1.55 2000/06/30 19:17:08 roberto Exp roberto $
** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: lua@tecgraf.puc-rio.br
@@ -30,6 +30,14 @@
#define LUA_ANYTAG (-1)
+
+/* error code for lua_do* */
+#define LUA_ERRFILE 2
+#define LUA_ERRSYNTAX 3
+#define LUA_ERRRUN 1
+#define LUA_ERRMEM 4
+
+
typedef struct lua_State lua_State;
typedef void (*lua_CFunction) (lua_State *L);
@@ -58,7 +66,7 @@ int lua_dostring (lua_State *L, const char *str);
int lua_dobuffer (lua_State *L, const char *buff, size_t size,
const char *name); /* Out: returns */
int lua_callfunction (lua_State *L, lua_Object f);
- /* In: parameters; Out: returns */
+ /* In: arguments; Out: returns */
void lua_beginblock (lua_State *L);
void lua_endblock (lua_State *L);
@@ -111,7 +119,7 @@ lua_Object lua_rawget (lua_State *L); /* In: table, index */
int lua_tag (lua_State *L, lua_Object obj);
int lua_next (lua_State *L, lua_Object o, int i);
- /* Out: ref, value */
+ /* Out: index, value */
int lua_ref (lua_State *L, int lock); /* In: value */
lua_Object lua_getref (lua_State *L, int ref);