--- stack/stack.c 2002/03/10 12:05:20 1.100 +++ stack/stack.c 2002/03/10 13:00:01 1.101 @@ -123,7 +123,7 @@ nitem->next= env->gc_ref; env->gc_ref= nitem; - env->gc_count+=sizeof(value); + env->gc_count += sizeof(value); nval->gc.flag.mark= 0; nval->gc.flag.protect= 0; @@ -167,7 +167,7 @@ int i; if(env->interactive){ - printf("Garbage collecting.", env->gc_count, env->gc_limit); + printf("Garbage collecting."); } /* Mark values on stack */ @@ -220,6 +220,8 @@ continue; } else { env->gc_count += sizeof(value); + if(env->gc_ref->item->type == string) + env->gc_count += strlen(env->gc_ref->item->content.ptr); } /* Keep values */ @@ -232,6 +234,7 @@ if (env->gc_limit < env->gc_count*2) env->gc_limit= env->gc_count*2; + env->gc_ref= new_head; if(env->interactive){ @@ -315,8 +318,10 @@ void push_cstring(environment *env, const char *in_string) { value *new_value= new_val(env); + int length= strlen(in_string)+1; - new_value->content.ptr= malloc(strlen(in_string)+1); + new_value->content.ptr= malloc(length); + env->gc_count += length; strcpy(new_value->content.ptr, in_string); new_value->type= string; @@ -1011,7 +1016,7 @@ } if(myenv.interactive) { - printf("Stack version $Revision: 1.100 $\n\ + printf("Stack version $Revision: 1.101 $\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\