History

suppressed another alloc

bellard committed 25 years ago

Commit cd526481 parent cdf62471 file · +6 −4Browse files

Unified · Split

tcc.c+6−4
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #define MACRO_STACK_SIZE 32
2828 #define INCLUDE_STACK_SIZE 32
2929 #define IFDEF_STACK_SIZE 64
30+#define VSTACK_SIZE 64
3031
3132 #define NB_REGS 3
3233
@@ -61,11 +62,11 @@ typedef struct { · 28 unmodified lines
6162 */
6263 FILE *file;
6364 int tok, tok1, tokc, rsym, anon_sym,
64− prog, ind, loc, glo, vt, *vstack, *vstack_ptr,
65− vc, line_num;
65+ prog, ind, loc, glo, vt, vc, line_num;
6666 char *idtable, *idptr, *filename;
6767 Sym *define_stack, *global_stack, *local_stack, *label_stack;
6868
69+int vstack[VSTACK_SIZE], *vstack_ptr;
6970 char *macro_stack[MACRO_STACK_SIZE], **macro_stack_ptr, *macro_ptr;
7071 IncludeFile include_stack[INCLUDE_STACK_SIZE], *include_stack_ptr;
7172 int ifdef_stack[IFDEF_STACK_SIZE], *ifdef_stack_ptr;
@@ -541,7 +542,7 @@ void preprocess() · 469 unmodified lines
541542 /* now 'tok' is the macro symbol */
542543 /* a space is inserted after each macro */
543544 str = get_str(' ');
544− printf("define %s '%s'\n", get_tok_str(tok), str);
545+ // printf("define %s '%s'\n", get_tok_str(tok), str);
545546 sym_push1(&define_stack, tok, 0, (int)str);
546547 } else if (tok == TOK_INCLUDE) {
547548 skip_spaces();
@@ -1105,6 +1106,8 @@ int gvp(int *p) · 557 unmodified lines
11051106
11061107 void vpush()
11071108 {
1109+ if (vstack_ptr >= vstack + VSTACK_SIZE)
1110+ error("memory full");
11081111 *vstack_ptr++ = vt;
11091112 *vstack_ptr++ = vc;
11101113 /* cannot let cpu flags if other instruction are generated */
@@ -2330,7 +2333,6 @@ int main(int c, char **v) · 1219 unmodified lines
23302333 glo = malloc(DATA_SIZE);
23312334 memset((void *)glo, 0, DATA_SIZE);
23322335 prog = malloc(TEXT_SIZE);
2333− vstack = malloc(256);
23342336 vstack_ptr = vstack;
23352337 macro_stack_ptr = macro_stack;
23362338 anon_sym = 1 << (31 - VT_STRUCT_SHIFT);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t