aboutsummaryrefslogtreecommitdiffstats
path: root/gc/finalize.c
diff options
context:
space:
mode:
Diffstat (limited to 'gc/finalize.c')
-rw-r--r--gc/finalize.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/gc/finalize.c b/gc/finalize.c
index a316010..0027bf1 100644
--- a/gc/finalize.c
+++ b/gc/finalize.c
@@ -207,7 +207,8 @@ signed_word * log_size_ptr;
UNLOCK();
ENABLE_SIGNALS();
# endif
- new_dl = GC_oom_fn(sizeof(struct disappearing_link));
+ new_dl = (struct disappearing_link *)
+ GC_oom_fn(sizeof(struct disappearing_link));
if (0 == new_dl) {
GC_finalization_failures++;
return(0);
@@ -433,7 +434,8 @@ finalization_mark_proc * mp;
UNLOCK();
ENABLE_SIGNALS();
# endif
- new_fo = GC_oom_fn(sizeof(struct finalizable_object));
+ new_fo = (struct finalizable_object *)
+ GC_oom_fn(sizeof(struct finalizable_object));
if (0 == new_fo) {
GC_finalization_failures++;
return;
@@ -759,8 +761,10 @@ int GC_should_invoke_finalizers GC_PROTO((void))
/* Should be called without allocation lock. */
int GC_invoke_finalizers()
{
- register struct finalizable_object * curr_fo;
- register int count = 0;
+ struct finalizable_object * curr_fo;
+ int count = 0;
+ word mem_freed_before;
+ GC_bool first_time = TRUE;
DCL_LOCK_STATE;
while (GC_finalize_now != 0) {
@@ -768,6 +772,10 @@ int GC_invoke_finalizers()
DISABLE_SIGNALS();
LOCK();
# endif
+ if (first_time) {
+ mem_freed_before = GC_mem_freed;
+ first_time = FALSE;
+ }
curr_fo = GC_finalize_now;
# ifdef THREADS
if (curr_fo != 0) GC_finalize_now = fo_next(curr_fo);
@@ -789,6 +797,11 @@ int GC_invoke_finalizers()
GC_free((GC_PTR)curr_fo);
# endif
}
+ if (mem_freed_before != GC_mem_freed) {
+ LOCK();
+ GC_finalizer_mem_freed += (GC_mem_freed - mem_freed_before);
+ UNLOCK();
+ }
return count;
}