123 |
nitem->next= env->gc_ref; |
nitem->next= env->gc_ref; |
124 |
env->gc_ref= nitem; |
env->gc_ref= nitem; |
125 |
|
|
126 |
env->gc_count+=sizeof(value); |
env->gc_count += sizeof(value); |
127 |
nval->gc.flag.mark= 0; |
nval->gc.flag.mark= 0; |
128 |
nval->gc.flag.protect= 0; |
nval->gc.flag.protect= 0; |
129 |
|
|
167 |
int i; |
int i; |
168 |
|
|
169 |
if(env->interactive){ |
if(env->interactive){ |
170 |
printf("Garbage collecting.", env->gc_count, env->gc_limit); |
printf("Garbage collecting."); |
171 |
} |
} |
172 |
|
|
173 |
/* Mark values on stack */ |
/* Mark values on stack */ |
220 |
continue; |
continue; |
221 |
} else { |
} else { |
222 |
env->gc_count += sizeof(value); |
env->gc_count += sizeof(value); |
223 |
|
if(env->gc_ref->item->type == string) |
224 |
|
env->gc_count += strlen(env->gc_ref->item->content.ptr); |
225 |
} |
} |
226 |
|
|
227 |
/* Keep values */ |
/* Keep values */ |
234 |
|
|
235 |
if (env->gc_limit < env->gc_count*2) |
if (env->gc_limit < env->gc_count*2) |
236 |
env->gc_limit= env->gc_count*2; |
env->gc_limit= env->gc_count*2; |
237 |
|
|
238 |
env->gc_ref= new_head; |
env->gc_ref= new_head; |
239 |
|
|
240 |
if(env->interactive){ |
if(env->interactive){ |
318 |
void push_cstring(environment *env, const char *in_string) |
void push_cstring(environment *env, const char *in_string) |
319 |
{ |
{ |
320 |
value *new_value= new_val(env); |
value *new_value= new_val(env); |
321 |
|
int length= strlen(in_string)+1; |
322 |
|
|
323 |
new_value->content.ptr= malloc(strlen(in_string)+1); |
new_value->content.ptr= malloc(length); |
324 |
|
env->gc_count += length; |
325 |
strcpy(new_value->content.ptr, in_string); |
strcpy(new_value->content.ptr, in_string); |
326 |
new_value->type= string; |
new_value->type= string; |
327 |
|
|