aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-05-11 11:19:32 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-05-11 11:19:32 -0300
commit6eb1399a1c662f45ab5511a5e7d35fdb967ec076 (patch)
treecec3750f9655d6abb1829cb0f2f72c5497d584f8
parentc390f73e3b3853fb64a057bdcc2a79fc87e13ad3 (diff)
downloadlua-6eb1399a1c662f45ab5511a5e7d35fdb967ec076.tar.gz
lua-6eb1399a1c662f45ab5511a5e7d35fdb967ec076.tar.bz2
lua-6eb1399a1c662f45ab5511a5e7d35fdb967ec076.zip
array Cblocks should grow dynamically
-rw-r--r--lapi.c26
-rw-r--r--lstate.c5
-rw-r--r--lstate.h7
3 files changed, 22 insertions, 16 deletions
diff --git a/lapi.c b/lapi.c
index 160459d8..e71eb4ae 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.41 1999/03/04 21:17:26 roberto Exp roberto $ 2** $Id: lapi.c,v 1.42 1999/03/26 13:14:00 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -637,16 +637,22 @@ char *lua_getobjname (lua_Object o, char **name)
637*/ 637*/
638 638
639 639
640void lua_beginblock (void) 640#ifndef MAX_C_BLOCKS
641{ 641#define MAX_C_BLOCKS 500
642 if (L->numCblocks >= MAX_C_BLOCKS) 642#endif
643 lua_error("too many nested blocks"); 643
644
645void lua_beginblock (void) {
646 if (L->numCblocks >= L->sizeCblocks) {
647 luaM_growvector(L->Cblocks, L->numCblocks, 1, struct C_Lua_Stack,
648 "too many nested blocks", MAX_C_BLOCKS);
649 L->sizeCblocks++;
650 }
644 L->Cblocks[L->numCblocks] = L->Cstack; 651 L->Cblocks[L->numCblocks] = L->Cstack;
645 L->numCblocks++; 652 L->numCblocks++;
646} 653}
647 654
648void lua_endblock (void) 655void lua_endblock (void) {
649{
650 --L->numCblocks; 656 --L->numCblocks;
651 L->Cstack = L->Cblocks[L->numCblocks]; 657 L->Cstack = L->Cblocks[L->numCblocks];
652 luaD_adjusttop(L->Cstack.base); 658 luaD_adjusttop(L->Cstack.base);
@@ -654,8 +660,7 @@ void lua_endblock (void)
654 660
655 661
656 662
657int lua_ref (int lock) 663int lua_ref (int lock) {
658{
659 int ref; 664 int ref;
660 checkCparams(1); 665 checkCparams(1);
661 ref = luaC_ref(L->stack.top-1, lock); 666 ref = luaC_ref(L->stack.top-1, lock);
@@ -665,8 +670,7 @@ int lua_ref (int lock)
665 670
666 671
667 672
668lua_Object lua_getref (int ref) 673lua_Object lua_getref (int ref) {
669{
670 TObject *o = luaC_getref(ref); 674 TObject *o = luaC_getref(ref);
671 return (o ? put_luaObject(o) : LUA_NOOBJECT); 675 return (o ? put_luaObject(o) : LUA_NOOBJECT);
672} 676}
diff --git a/lstate.c b/lstate.c
index be5acf0c..931f0c5a 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.9 1999/02/25 15:17:01 roberto Exp roberto $ 2** $Id: lstate.c,v 1.10 1999/04/13 19:30:51 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*/
@@ -32,6 +32,8 @@ void lua_open (void)
32 L->Mbuffbase = 0; 32 L->Mbuffbase = 0;
33 L->Mbuffsize = 0; 33 L->Mbuffsize = 0;
34 L->Mbuffnext = 0; 34 L->Mbuffnext = 0;
35 L->Cblocks = NULL;
36 L->sizeCblocks = 0;
35 L->numCblocks = 0; 37 L->numCblocks = 0;
36 L->debug = 0; 38 L->debug = 0;
37 L->callhook = NULL; 39 L->callhook = NULL;
@@ -73,6 +75,7 @@ void lua_close (void)
73 luaM_free(L->IMtable); 75 luaM_free(L->IMtable);
74 luaM_free(L->refArray); 76 luaM_free(L->refArray);
75 luaM_free(L->Mbuffer); 77 luaM_free(L->Mbuffer);
78 luaM_free(L->Cblocks);
76 luaM_free(L); 79 luaM_free(L);
77 L = NULL; 80 L = NULL;
78#ifdef DEBUG 81#ifdef DEBUG
diff --git a/lstate.h b/lstate.h
index 795a6008..541c473d 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 1.16 1999/04/13 19:30:51 roberto Exp roberto $ 2** $Id: lstate.h,v 1.17 1999/05/10 13:54:01 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*/
@@ -14,8 +14,6 @@
14#include "luadebug.h" 14#include "luadebug.h"
15 15
16 16
17#define MAX_C_BLOCKS 10
18
19#define GARBAGE_BLOCK 150 17#define GARBAGE_BLOCK 150
20 18
21 19
@@ -69,7 +67,8 @@ struct lua_State {
69 int Mbuffbase; /* current first position of Mbuffer */ 67 int Mbuffbase; /* current first position of Mbuffer */
70 int Mbuffsize; /* size of Mbuffer */ 68 int Mbuffsize; /* size of Mbuffer */
71 int Mbuffnext; /* next position to fill in Mbuffer */ 69 int Mbuffnext; /* next position to fill in Mbuffer */
72 struct C_Lua_Stack Cblocks[MAX_C_BLOCKS]; 70 struct C_Lua_Stack *Cblocks;
71 int sizeCblocks; /* size of Cblocks */
73 int numCblocks; /* number of nested Cblocks */ 72 int numCblocks; /* number of nested Cblocks */
74 int debug; 73 int debug;
75 lua_CHFunction callhook; 74 lua_CHFunction callhook;