Mercurial > hg > CbC > old > device
changeset 357:1057d6740a36
*** empty log message ***
author | kono |
---|---|
date | Sun, 04 Jul 2004 22:08:46 +0900 |
parents | 6818bd03767d |
children | 4f1fe3731ff0 |
files | Changes mc-parse.c mc-parse.h mc.h stdio.h |
diffstat | 5 files changed, 42 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sun Jul 04 21:08:32 2004 +0900 +++ b/Changes Sun Jul 04 22:08:46 2004 +0900 @@ -5461,3 +5461,33 @@ global heap は拡張可能じゃない? local heap がない時に、 やばそうだったら拡張してしまう。realloc でいいし。 pointer とっているのは scope だけじゃないか? + +うーん、やっぱり、global heap の拡張は、それほど単純じゃない +みたいね。 + + +41c41,43 +< int args,init_vars,heap[HEAPSIZE]; +--- +> int args,init_vars; +> int *heap; +> static int HEAPSIZE = HEAPSIZE0; +236a234,245 +> void +> clear_lfree() +> { +> if (gfree>HEAPSIZE-LHEAPMARGIN) { +> HEAPSIZE *= 2; +> heap = realloc(heap,HEAPSIZE*sizeof(int)); +> if (!heap) error(MMERR); +> fprintf(stderr,"heap extended to %d\n",HEAPSIZE); +> } +> lfree= HEAPSIZE; +> } +> static void +331a353,354 +> if (!heap) heap = (int *)malloc(HEAPSIZE*sizeof(int)); +> if (!heap) error(MMERR); + +ぐらいではぜんぜんだめ。 +
--- a/mc-parse.c Sun Jul 04 21:08:32 2004 +0900 +++ b/mc-parse.c Sun Jul 04 22:08:46 2004 +0900 @@ -38,7 +38,9 @@ char linebuf[LBUFSIZE]; char *chptr; -int args,init_vars,heap[HEAPSIZE]; +int args,init_vars; +int *heap; +int heapsize = HEAPSIZE; int asmf; int bit_field_disp; int blabel,dlabel; @@ -215,7 +217,7 @@ init(); while(1) { mode=TOP; - lfree= HEAPSIZE; + lfree= heapsize; codegen_decl_init(); while (chptrsave!=0) { i = cadr(chptrsave); free_glist2(chptrsave); chptrsave = i; @@ -327,9 +329,11 @@ heap_init() { gpc=glineno=0; + if (!heap) heap = (int *)malloc(heapsize*sizeof(int)); + if (!heap) error(MMERR); gfree=ilabel=1; labelno=2; - lfree=HEAPSIZE; + lfree=heapsize; } static void
--- a/mc-parse.h Sun Jul 04 21:08:32 2004 +0900 +++ b/mc-parse.h Sun Jul 04 22:08:46 2004 +0900 @@ -2,7 +2,7 @@ extern int sym,type,mode,stmode; extern int labelno,gpc,disp; -extern int args,init_vars,heap[HEAPSIZE]; +extern int args,init_vars; extern int cslabel,control; extern NMTBL *nptr,*gnptr; extern NMTBL *fnptr;
--- a/mc.h Sun Jul 04 21:08:32 2004 +0900 +++ b/mc.h Sun Jul 04 22:08:46 2004 +0900 @@ -421,7 +421,7 @@ #define MAX_INCLUDE_PATH_COUNT 10 #define GSYMS 8192 -#define HEAPSIZE 30000*2*6 +#define HEAPSIZE 30000*2 #define CHEAPSIZE (sizeof(NMTBL)*GSYMS) #define LBUFSIZE 4096 #define STRSIZE 4096 @@ -431,7 +431,7 @@ struct nametable *next; int sc,ty,dsp; } NMTBL; -extern int heap[HEAPSIZE]; +extern int *heap; extern NMTBL *global_list,*local_static_list; #if FLOAT_CODE
--- a/stdio.h Sun Jul 04 21:08:32 2004 +0900 +++ b/stdio.h Sun Jul 04 22:08:46 2004 +0900 @@ -1,7 +1,8 @@ -#ifndef __micro_c__aaa +#ifndef __micro_c__ #include "/usr/include/stdio.h" long long strtoll(const char *, char **, int); char *malloc(int); +void * realloc(void *ptr, size_t size); #else long long strtoll(const char *, char **, int);