--- stack/stack.c 2002/03/10 10:06:36 1.99 +++ stack/stack.c 2002/03/10 12:05:20 1.100 @@ -48,7 +48,7 @@ { int i; - env->gc_limit= 200; + env->gc_limit= 400000; env->gc_count= 0; env->gc_ref= NULL; @@ -80,8 +80,6 @@ env->head= env->head->next; /* Remove the top stack item */ free(temp); /* Free the old top stack item */ - - env->gc_limit--; } /* Returns a pointer to a pointer to an element in the hash table. */ @@ -125,7 +123,7 @@ nitem->next= env->gc_ref; env->gc_ref= nitem; - env->gc_count++; + env->gc_count+=sizeof(value); nval->gc.flag.mark= 0; nval->gc.flag.protect= 0; @@ -168,6 +166,10 @@ symbol *tsymb; int i; + if(env->interactive){ + printf("Garbage collecting.", env->gc_count, env->gc_limit); + } + /* Mark values on stack */ iterator= env->head; while(iterator!=NULL) { @@ -175,6 +177,10 @@ iterator= iterator->next; } + if(env->interactive){ + printf("."); + } + /* Mark values in hashtable */ for(i= 0; isymbols[i]; @@ -185,6 +191,10 @@ } } + if(env->interactive){ + printf("."); + } + env->gc_count= 0; while(env->gc_ref!=NULL) { /* Sweep unused values */ @@ -208,6 +218,8 @@ free(env->gc_ref); /* Remove value */ env->gc_ref= titem; continue; + } else { + env->gc_count += sizeof(value); } /* Keep values */ @@ -216,11 +228,16 @@ new_head= env->gc_ref; new_head->item->gc.flag.mark= 0; env->gc_ref= titem; - env->gc_count++; } - env->gc_limit= env->gc_count*2; + if (env->gc_limit < env->gc_count*2) + env->gc_limit= env->gc_count*2; env->gc_ref= new_head; + + if(env->interactive){ + printf("done\n"); + } + } /* Protect values from GC */ @@ -662,7 +679,7 @@ push_val(env, iterator->item); if(env->head->item->type==symb - && strcmp(";", ((symbol*)(env->head->item->content.ptr))->id)==0) { + && (((symbol*)(env->head->item->content.ptr))->id[0] == ';')) { toss(env); if(env->err) return; @@ -994,7 +1011,7 @@ } if(myenv.interactive) { - printf("Stack version $Revision: 1.99 $\n\ + printf("Stack version $Revision: 1.100 $\n\ Copyright (C) 2002 Mats Alritzson and Teddy Hogeborn\n\ Stack comes with ABSOLUTELY NO WARRANTY; for details type `warranty;'.\n\ This is free software, and you are welcome to redistribute it\n\