aboutsummaryrefslogtreecommitdiff
path: root/lua.stx
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-03-21 13:33:47 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-03-21 13:33:47 -0300
commit9284742a11b92dfe4ef011b963240cfa588515cd (patch)
tree96cc498fcc5ec27546fc0738998319c829df55d0 /lua.stx
parent9704ff4cb14f34077062447d15196d32ace23e95 (diff)
downloadlua-9284742a11b92dfe4ef011b963240cfa588515cd.tar.gz
lua-9284742a11b92dfe4ef011b963240cfa588515cd.tar.bz2
lua-9284742a11b92dfe4ef011b963240cfa588515cd.zip
better control when growing arrays.
Diffstat (limited to 'lua.stx')
-rw-r--r--lua.stx13
1 files changed, 3 insertions, 10 deletions
diff --git a/lua.stx b/lua.stx
index 47925c33..5df83550 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
1%{ 1%{
2 2
3char *rcs_luastx = "$Id: lua.stx,v 3.34 1996/02/26 21:00:27 roberto Exp roberto $"; 3char *rcs_luastx = "$Id: lua.stx,v 3.35 1996/03/08 12:02:37 roberto Exp roberto $";
4 4
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h> 6#include <stdlib.h>
@@ -31,7 +31,7 @@ int yyparse (void);
31#endif 31#endif
32static int maxcode; 32static int maxcode;
33static int maxmain; 33static int maxmain;
34static Long maxcurr; /* to allow maxcurr *= 2 without overflow */ 34static int maxcurr;
35static Byte *funcCode = NULL; 35static Byte *funcCode = NULL;
36static Byte **initcode; 36static Byte **initcode;
37static Byte *basepc; 37static Byte *basepc;
@@ -70,14 +70,7 @@ static void yyerror (char *s)
70static void code_byte (Byte c) 70static void code_byte (Byte c)
71{ 71{
72 if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ 72 if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */
73 { 73 maxcurr = growvector(&basepc, maxcurr, Byte, codeEM, MAX_INT);
74 if (maxcurr >= MAX_INT)
75 yyerror("code size overflow");
76 maxcurr *= 2;
77 if (maxcurr >= MAX_INT)
78 maxcurr = MAX_INT;
79 basepc = growvector(basepc, maxcurr, Byte);
80 }
81 basepc[pc++] = c; 74 basepc[pc++] = c;
82} 75}
83 76