summaryrefslogtreecommitdiff
path: root/fnlz_mlc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-11-29 11:46:48 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-11-29 11:46:48 +0300
commit328509d459ee420c839e51acac12aa1d71d829a5 (patch)
treebaedc308f0f1f9aabeaf45692487ea14d31b5785 /fnlz_mlc.c
parent945afca717982db4363e6241a5da80a5999afed2 (diff)
downloadbdwgc-328509d459ee420c839e51acac12aa1d71d829a5.tar.gz
Fix GC_register_disclaim_proc for leak-finding mode
Issue #252 (bdwgc). This makes the behavior of GC_register_disclaim_proc() and GC_finalized_malloc() somewhat consistent with GC_register_disappearing_link() and GC_register_finalizer() when find-leak is on. The documentation is updated accordingly. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Add assertion that GC_find_leak is off. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_register_disclaim_proc): Do not assign ok_disclaim_proc, ok_mark_unconditionally fields if GC_find_leak. * include/gc_disclaim.h (GC_register_disclaim_proc, GC_finalized_malloc): Refine comment about leak-find mode and GC_free invocation.
Diffstat (limited to 'fnlz_mlc.c')
-rw-r--r--fnlz_mlc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fnlz_mlc.c b/fnlz_mlc.c
index 1e1a6ed0..283566ee 100644
--- a/fnlz_mlc.c
+++ b/fnlz_mlc.c
@@ -45,6 +45,7 @@ STATIC int GC_CALLBACK GC_finalized_disclaim(void *obj)
const struct GC_finalizer_closure *fc
= (struct GC_finalizer_closure *)(fc_word
& ~(word)FINALIZER_CLOSURE_FLAG);
+ GC_ASSERT(!GC_find_leak);
(*fc->proc)((word *)obj + 1, fc->cd);
}
return 0;
@@ -85,8 +86,11 @@ GC_API void GC_CALL GC_register_disclaim_proc(int kind, GC_disclaim_proc proc,
{
GC_ASSERT((unsigned)kind < MAXOBJKINDS);
GC_ASSERT(NONNULL_ARG_NOT_NULL(proc));
- GC_obj_kinds[kind].ok_disclaim_proc = proc;
- GC_obj_kinds[kind].ok_mark_unconditionally = (GC_bool)mark_unconditionally;
+ if (!EXPECT(GC_find_leak, FALSE)) {
+ GC_obj_kinds[kind].ok_disclaim_proc = proc;
+ GC_obj_kinds[kind].ok_mark_unconditionally =
+ (GC_bool)mark_unconditionally;
+ }
}
GC_API GC_ATTR_MALLOC void * GC_CALL GC_finalized_malloc(size_t lb,