/[cvs]/stack/stack.c
ViewVC logotype

Diff of /stack/stack.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.100 by teddy, Sun Mar 10 12:05:20 2002 UTC revision 1.101 by teddy, Sun Mar 10 13:00:01 2002 UTC
# Line 123  value* new_val(environment *env) Line 123  value* new_val(environment *env)
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    
# Line 167  extern void gc_init(environment *env) Line 167  extern void gc_init(environment *env)
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 */
# Line 220  extern void gc_init(environment *env) Line 220  extern void gc_init(environment *env)
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 */
# Line 232  extern void gc_init(environment *env) Line 234  extern void gc_init(environment *env)
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){
# Line 315  void push_float(environment *env, float Line 318  void push_float(environment *env, float
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    

Legend:
Removed from v.1.100  
changed lines
  Added in v.1.101

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26