Mercurial > hg > CbC > old > device
changeset 358:4f1fe3731ff0
realloc heap
author | kono |
---|---|
date | Sun, 04 Jul 2004 22:20:44 +0900 |
parents | 1057d6740a36 |
children | 7ab4434ad869 |
files | Changes mc-parse.c mc.h |
diffstat | 3 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sun Jul 04 22:08:46 2004 +0900 +++ b/Changes Sun Jul 04 22:20:44 2004 +0900 @@ -5491,3 +5491,4 @@ ぐらいではぜんぜんだめ。 +別に問題なくできるじゃん。なにやってんだ?
--- a/mc-parse.c Sun Jul 04 22:08:46 2004 +0900 +++ b/mc-parse.c Sun Jul 04 22:20:44 2004 +0900 @@ -22,6 +22,7 @@ extern double strtod(const char *nptr, char **endptr); #endif +#define HEAP_REPORT 0 NMTBL null_nptr; NMTBL *fnptr; @@ -217,6 +218,13 @@ init(); while(1) { mode=TOP; + if (gfree > heapsize-30000) { + heapsize *= 2; +#if HEAP_REPORT + fprintf(stderr,"** heap extended to %d\n",heapsize); +#endif + heap = realloc(heap,heapsize*sizeof(int)); + } lfree= heapsize; codegen_decl_init(); while (chptrsave!=0) { @@ -2911,6 +2919,9 @@ struct cheap *p = (struct cheap *)malloc(sizeof(struct cheap)); if (!p) error(MMERR); // fatal p->ptr = p->first = (char *)malloc(CHEAPSIZE); +#if HEAP_REPORT + fprintf(stderr,"** new cheap %d\n",(int)CHEAPSIZE); +#endif p->last = p->first + CHEAPSIZE; if (!p->ptr) error(MMERR); // fatal p->next = 0; @@ -3411,6 +3422,9 @@ if (nptr_pool->next) { nptr_pool = nptr_pool->next; } else { +#if HEAP_REPORT + fprintf(stderr,"** nptr extended\n"); +#endif nptr_pool->next = new_cheap(); nptr_pool = nptr_pool->next; }