From: hboehm Date: Wed, 24 Oct 2007 00:38:41 +0000 (+0000) Subject: 2007-10-23 Hans Boehm X-Git-Tag: gc7_1alpha2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6bd946e18d7ec227ee1c295b3d0122758c07511e;p=gc 2007-10-23 Hans Boehm * malloc.c: Update GC_large_allocd_bytes on explicit deallocation. * allchblk.c: Sanity check GC_max_large_allocd_bytes. --- diff --git a/ChangeLog b/ChangeLog index 18cb8e45..b3fa4f50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-10-23 Hans Boehm + + * malloc.c: Update GC_large_allocd_bytes on explicit deallocation. + * allchblk.c: Sanity check GC_max_large_allocd_bytes. + 2007-10-23 Hans Boehm (Really Manuel Serrano) * Makefile.direct: Invoke $(MAKE) instead of make. diff --git a/allchblk.c b/allchblk.c index 0cec29d6..807a703b 100644 --- a/allchblk.c +++ b/allchblk.c @@ -59,6 +59,8 @@ struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 }; static GC_bool GC_enough_large_bytes_left(word bytes, int n) { int i; + + GC_ASSERT(GC_max_large_allocd_bytes <= GC_heapsize); for (i = N_HBLK_FLS; i >= n; --i) { bytes += GC_free_bytes[i]; if (bytes > GC_max_large_allocd_bytes) return TRUE; diff --git a/malloc.c b/malloc.c index 47950489..c03dc741 100644 --- a/malloc.c +++ b/malloc.c @@ -438,9 +438,13 @@ void GC_free(void * p) *flh = (ptr_t)p; UNLOCK(); } else { + size_t nblocks = OBJ_SZ_TO_BLOCKS(sz); LOCK(); GC_bytes_freed += sz; if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= sz; + if (nblocks > 1) { + GC_large_allocd_bytes -= nblocks * HBLKSIZE; + } GC_freehblk(h); UNLOCK(); } @@ -477,8 +481,12 @@ void GC_free_inner(void * p) obj_link(p) = *flh; *flh = (ptr_t)p; } else { + size_t nblocks = OBJ_SZ_TO_BLOCKS(sz); GC_bytes_freed += sz; if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= sz; + if (nblocks > 1) { + GC_large_allocd_bytes -= nblocks * HBLKSIZE; + } GC_freehblk(h); } }