diff --git a/gc.c b/gc.c index e5aa0144..fc6a37ce 100644 --- a/gc.c +++ b/gc.c @@ -277,12 +277,16 @@ void sexp_conservative_mark (sexp ctx) { #endif #if SEXP_USE_WEAK_REFERENCES -void sexp_reset_weak_references(sexp ctx) { - int i, len, all_reset_p; - sexp_heap h = sexp_context_heap(ctx); +int sexp_reset_weak_references(sexp ctx) { + int i, len, broke, all_reset_p; + sexp_heap h; sexp p, t, end, *v; sexp_free_list q, r; - for ( ; h; h=h->next) { /* just scan the whole heap */ + if (sexp_not(sexp_global(ctx, SEXP_G_WEAK_OBJECTS_PRESENT))) + return 0; + broke = 0; + /* just scan the whole heap */ + for (h = sexp_context_heap(ctx) ; h; h=h->next) { p = sexp_heap_first_block(h); q = h->free_list; end = sexp_heap_end(h); @@ -309,6 +313,7 @@ void sexp_reset_weak_references(sexp ctx) { } } if (all_reset_p) { /* ephemerons */ + broke++; len += sexp_type_weak_len_extra(t); for ( ; i