aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldo.c31
-rw-r--r--lmem.h5
2 files changed, 16 insertions, 20 deletions
diff --git a/ldo.c b/ldo.c
index 5b03633f..2318dd81 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.10 1997/11/21 19:00:46 roberto Exp roberto $ 2** $Id: ldo.c,v 1.11 1997/11/26 20:28:22 roberto Exp $
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*/
@@ -52,33 +52,32 @@ static void initCfunc (TObject *o, lua_CFunction f)
52} 52}
53 53
54 54
55#define STACK_EXTRA 32 55#define STACK_UNIT 128
56#define INIT_STACK_SIZE 32
57 56
58 57
59void luaD_init (void) 58void luaD_init (void)
60{ 59{
61 L->stack.stack = luaM_newvector(INIT_STACK_SIZE, TObject); 60 L->stack.stack = luaM_newvector(STACK_UNIT, TObject);
62 L->stack.top = L->stack.stack; 61 L->stack.top = L->stack.stack;
63 L->stack.last = L->stack.stack+(INIT_STACK_SIZE-1); 62 L->stack.last = L->stack.stack+(STACK_UNIT-1);
64 initCfunc(&L->errorim, stderrorim); 63 initCfunc(&L->errorim, stderrorim);
65} 64}
66 65
67 66
68void luaD_checkstack (int n) 67void luaD_checkstack (int n)
69{ 68{
70 if (L->stack.last-L->stack.top <= n) { 69 struct Stack *S = &L->stack;
71 StkId top = L->stack.top-L->stack.stack; 70 if (S->last-S->top <= n) {
72 int stacksize = (L->stack.last-L->stack.stack)+1+STACK_EXTRA+n; 71 StkId top = S->top-S->stack;
73 L->stack.stack = luaM_reallocvector(L->stack.stack, stacksize, TObject); 72 int stacksize = (S->last-S->stack)+1+STACK_UNIT+n;
74 L->stack.last = L->stack.stack+(stacksize-1); 73 S->stack = luaM_reallocvector(S->stack, stacksize, TObject);
75 L->stack.top = L->stack.stack + top; 74 S->last = S->stack+(stacksize-1);
76 if (stacksize >= STACK_LIMIT) { 75 S->top = S->stack + top;
77 if (lua_stackedfunction(100) == LUA_NOOBJECT) 76 if (stacksize >= STACK_LIMIT) { /* stack overflow? */
78 /* doesn't look like a recursive loop */ 77 if (lua_stackedfunction(100) == LUA_NOOBJECT) /* 100 funcs on stack? */
79 lua_error("Lua2C - C2Lua overflow"); 78 lua_error("Lua2C - C2Lua overflow"); /* doesn't look like a rec. loop */
80 else 79 else
81 lua_error(stackEM); 80 lua_error("stack size overflow");
82 } 81 }
83 } 82 }
84} 83}
diff --git a/lmem.h b/lmem.h
index 90111336..8d4bd32c 100644
--- a/lmem.h
+++ b/lmem.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $ 2** $Id: lmem.h,v 1.2 1997/11/26 18:53:45 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*/
@@ -15,10 +15,7 @@
15 15
16/* memory error messages */ 16/* memory error messages */
17#define codeEM "code size overflow" 17#define codeEM "code size overflow"
18#define symbolEM "symbol table overflow"
19#define constantEM "constant table overflow" 18#define constantEM "constant table overflow"
20#define stackEM "stack size overflow"
21#define lexEM "lex buffer overflow"
22#define refEM "reference table overflow" 19#define refEM "reference table overflow"
23#define tableEM "table overflow" 20#define tableEM "table overflow"
24#define memEM "not enough memory" 21#define memEM "not enough memory"