Branch: Tag:

1996-03-28

1996-03-28 21:33:36 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

garbage collect rewritten

Rev: src/array.c:1.9
Rev: src/array.h:1.6
Rev: src/gc.c:1.2
Rev: src/gc.h:1.2
Rev: src/list.c:1.3
Rev: src/list.h:1.2
Rev: src/mapping.c:1.4
Rev: src/mapping.h:1.3
Rev: src/object.c:1.8
Rev: src/object.h:1.5
Rev: src/program.c:1.8
Rev: src/program.h:1.4
Rev: src/svalue.c:1.8

14:   #include "dynamic_buffer.h"   #include "interpret.h"   #include "builtin_efuns.h" + #include "gc.h"      struct list *first_list;   
28:   static struct list *allocate_list(struct array *ind)   {    struct list *l; +  GC_ALLOC();    l=ALLOC_STRUCT(list);    l->next = first_list;    l->prev = 0;
56:    if(first_list == l) first_list = 0;       free((char *)l); +  GC_FREE();   }      static void order_list(struct list *l)
247:    }    }    -  ret=allocate_list(0); +  ret=allocate_list( & empty_array );    doing.pointer_b=(void *)ret;       ret->ind=copy_array_recursively(l->ind,&doing);
256:       return ret;   } +  +  + #ifdef GC2 +  + void gc_mark_list_as_referenced(struct list *l) + { +  if(gc_mark(l)) +  gc_mark_array_as_referenced(l->ind); + } +  + void gc_check_all_lists() + { +  struct list *l; +  for(l=first_list;l;l=l->next) +  gc_check(l->ind); + } +  + void gc_mark_all_lists() + { +  struct list *l; +  for(l=first_list;l;l=l->next) +  if(gc_is_referenced(l)) +  gc_mark_list_as_referenced(l); + } +  + void gc_free_all_unreferenced_lists() + { +  struct list *l,*next; +  +  for(l=first_list;l;l=next) +  { +  if(gc_do_free(l)) +  { +  l->refs++; +  free_svalues(ITEM(l->ind), l->ind->size, l->ind->type_field); +  l->ind->size=0; +  next=l->next; +  +  free_list(l); +  }else{ +  next=l->next; +  } +  } + } +  + #endif /* GC2 */