diff options
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | gc.h | 2 | ||||
-rw-r--r-- | hash.c | 19 |
3 files changed, 16 insertions, 7 deletions
@@ -43,8 +43,6 @@ #define PROT_STACK_SIZE 1024 #define HEAP_SIZE 16384 -#define REACHABLE 0x100 -#define FREE 0x200 typedef struct heap { struct heap *next; @@ -36,3 +36,5 @@ int gc_is_reachable(val); void unmark(void); void gc_hint_func(val *); #define gc_hint(var) gc_hint_func(&var) +#define REACHABLE 0x100 +#define FREE 0x200 @@ -159,7 +159,7 @@ static void hash_mark(val hash) gc_mark(cdr(entry)); } } - reachable_weak_hashes->next = h; + h->next = reachable_weak_hashes; reachable_weak_hashes = h; break; case hash_weak_vals: @@ -175,7 +175,7 @@ static void hash_mark(val hash) gc_mark(car(entry)); } } - reachable_weak_hashes->next = h; + h->next = reachable_weak_hashes; reachable_weak_hashes = h; break; case hash_weak_both: @@ -299,7 +299,10 @@ void hash_process_weak(void) val *iter; for (iter = pchain; *iter != nil; ) { - val entry = car(*iter); + val entry; + (*iter)->t.type &= ~REACHABLE; + entry = car(*iter); + entry->t.type &= ~REACHABLE; if (!gc_is_reachable(car(entry))) *iter = cdr(*iter); else @@ -318,7 +321,10 @@ void hash_process_weak(void) val *iter; for (iter = pchain; *iter != nil; ) { - val entry = car(*iter); + val entry; + (*iter)->t.type &= ~REACHABLE; + entry = car(*iter); + entry->t.type &= ~REACHABLE; if (!gc_is_reachable(cdr(entry))) *iter = cdr(*iter); else @@ -337,7 +343,10 @@ void hash_process_weak(void) val *iter; for (iter = pchain; *iter != nil; ) { - val entry = car(*iter); + val entry; + (*iter)->t.type &= ~REACHABLE; + entry = car(*iter); + entry->t.type &= ~REACHABLE; if (!gc_is_reachable(car(entry)) || !gc_is_reachable(cdr(entry))) *iter = cdr(*iter); else |