diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-03-21 13:33:47 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-03-21 13:33:47 -0300 |
| commit | 9284742a11b92dfe4ef011b963240cfa588515cd (patch) | |
| tree | 96cc498fcc5ec27546fc0738998319c829df55d0 /lua.stx | |
| parent | 9704ff4cb14f34077062447d15196d32ace23e95 (diff) | |
| download | lua-9284742a11b92dfe4ef011b963240cfa588515cd.tar.gz lua-9284742a11b92dfe4ef011b963240cfa588515cd.tar.bz2 lua-9284742a11b92dfe4ef011b963240cfa588515cd.zip | |
better control when growing arrays.
Diffstat (limited to 'lua.stx')
| -rw-r--r-- | lua.stx | 13 |
1 files changed, 3 insertions, 10 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | %{ | 1 | %{ |
| 2 | 2 | ||
| 3 | char *rcs_luastx = "$Id: lua.stx,v 3.34 1996/02/26 21:00:27 roberto Exp roberto $"; | 3 | char *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 |
| 32 | static int maxcode; | 32 | static int maxcode; |
| 33 | static int maxmain; | 33 | static int maxmain; |
| 34 | static Long maxcurr; /* to allow maxcurr *= 2 without overflow */ | 34 | static int maxcurr; |
| 35 | static Byte *funcCode = NULL; | 35 | static Byte *funcCode = NULL; |
| 36 | static Byte **initcode; | 36 | static Byte **initcode; |
| 37 | static Byte *basepc; | 37 | static Byte *basepc; |
| @@ -70,14 +70,7 @@ static void yyerror (char *s) | |||
| 70 | static void code_byte (Byte c) | 70 | static 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 | ||
