diff --git a/dbg_mlc.c b/dbg_mlc.c index 138f747bd..291bf2e28 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -293,8 +293,8 @@ static void *store_debug_info(void *p, size_t lb, LOCK(); if (!GC_debugging_started) GC_start_debugging_inner(); - ADD_CALL_CHAIN(p, ra); result = GC_store_debug_info_inner(p, (word)lb, s, i); + ADD_CALL_CHAIN(p, ra); UNLOCK(); return result; } @@ -552,10 +552,11 @@ GC_API GC_ATTR_MALLOC void * GC_CALL /* We assume we already hold the GC lock. */ GC_INNER void * GC_debug_generic_malloc_inner(size_t lb, int k) { - void * result = GC_generic_malloc_inner( + void *base = GC_generic_malloc_inner( SIZET_SAT_ADD(lb, DEBUG_BYTES), k); + void *result; - if (result == 0) { + if (NULL == base) { GC_err_printf("GC internal allocation (%lu bytes) returning NULL\n", (unsigned long) lb); return(0); @@ -563,17 +564,19 @@ GC_API GC_ATTR_MALLOC void * GC_CALL if (!GC_debugging_started) { GC_start_debugging_inner(); } - ADD_CALL_CHAIN(result, GC_RETURN_ADDR); - return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", 0)); + result = GC_store_debug_info_inner(base, (word)lb, "INTERNAL", 0); + ADD_CALL_CHAIN(base, GC_RETURN_ADDR); + return result; } GC_INNER void * GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k) { - void * result = GC_generic_malloc_inner_ignore_off_page( + void *base = GC_generic_malloc_inner_ignore_off_page( SIZET_SAT_ADD(lb, DEBUG_BYTES), k); + void *result; - if (result == 0) { + if (NULL == base) { GC_err_printf("GC internal allocation (%lu bytes) returning NULL\n", (unsigned long) lb); return(0); @@ -581,8 +584,9 @@ GC_API GC_ATTR_MALLOC void * GC_CALL if (!GC_debugging_started) { GC_start_debugging_inner(); } - ADD_CALL_CHAIN(result, GC_RETURN_ADDR); - return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", 0)); + result = GC_store_debug_info_inner(base, (word)lb, "INTERNAL", 0); + ADD_CALL_CHAIN(base, GC_RETURN_ADDR); + return result; } #endif /* DBG_HDRS_ALL */ diff --git a/gcj_mlc.c b/gcj_mlc.c index 4c69e4a44..5620701f1 100644 --- a/gcj_mlc.c +++ b/gcj_mlc.c @@ -209,28 +209,28 @@ static void maybe_finalize(void) GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr, GC_EXTRA_PARAMS) { - void * result; + void *base, *result; DCL_LOCK_STATE; /* We're careful to avoid extra calls, which could */ /* confuse the backtrace. */ LOCK(); maybe_finalize(); - result = GC_generic_malloc_inner(SIZET_SAT_ADD(lb, DEBUG_BYTES), - GC_gcj_debug_kind); - if (result == 0) { + base = GC_generic_malloc_inner(SIZET_SAT_ADD(lb, DEBUG_BYTES), + GC_gcj_debug_kind); + if (NULL == base) { GC_oom_func oom_fn = GC_oom_fn; UNLOCK(); GC_err_printf("GC_debug_gcj_malloc(%lu, %p) returning NULL (%s:%d)\n", (unsigned long)lb, ptr_to_struct_containing_descr, s, i); return((*oom_fn)(lb)); } - *((void **)((ptr_t)result + sizeof(oh))) = ptr_to_struct_containing_descr; + *((void **)((ptr_t)base + sizeof(oh))) = ptr_to_struct_containing_descr; if (!GC_debugging_started) { GC_start_debugging_inner(); } - ADD_CALL_CHAIN(result, ra); - result = GC_store_debug_info_inner(result, (word)lb, s, i); + result = GC_store_debug_info_inner(base, (word)lb, s, i); + ADD_CALL_CHAIN(base, ra); UNLOCK(); GC_dirty(result); REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr);