From d3eb7db9e53a42a681ac99d2ff8d7a00f8ce1002 Mon Sep 17 00:00:00 2001 From: hboehm Date: Thu, 3 Jan 2008 01:21:05 +0000 Subject: [PATCH] 2007-01-02 Hans Boehm * alloc.c (GC_add_to_heap): Call GC_install_header(p) AFTER adjusting p. --- ChangeLog | 5 +++++ alloc.c | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0df263f0..1623bb5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-01-02 Hans Boehm + + * alloc.c (GC_add_to_heap): Call GC_install_header(p) AFTER + adjusting p. + 2007-12-23 Hans Boehm * Makefile.am: Add NT_X64_THREADS_MAKEFILE. diff --git a/alloc.c b/alloc.c index 426ab5a5..f996bff0 100644 --- a/alloc.c +++ b/alloc.c @@ -797,13 +797,6 @@ void GC_add_to_heap(struct hblk *p, size_t bytes) if (GC_n_heap_sects >= MAX_HEAP_SECTS) { ABORT("Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS"); } - phdr = GC_install_header(p); - if (0 == phdr) { - /* This is extremely unlikely. Can't add it. This will */ - /* almost certainly result in a 0 return from the allocator, */ - /* which is entirely appropriate. */ - return; - } while ((word)p <= HBLKSIZE) { /* Can't handle memory near address zero. */ ++p; @@ -817,6 +810,13 @@ void GC_add_to_heap(struct hblk *p, size_t bytes) if (0 == bytes) return; endp -= HBLKSIZE; } + phdr = GC_install_header(p); + if (0 == phdr) { + /* This is extremely unlikely. Can't add it. This will */ + /* almost certainly result in a 0 return from the allocator, */ + /* which is entirely appropriate. */ + return; + } GC_ASSERT(endp > (word)p && endp == (word)p + bytes); GC_heap_sects[GC_n_heap_sects].hs_start = (ptr_t)p; GC_heap_sects[GC_n_heap_sects].hs_bytes = bytes; -- 2.40.0