]>
Commit | Line | Data |
---|---|---|
189935b1 | 1 | diff -rbud gc6.5/include/gc.h gc6.5.patched/include/gc.h |
2 | --- gc6.5/include/gc.h Sat May 21 05:50:58 2005 | |
3 | +++ gc6.5.patched/include/gc.h Sat Jun 25 00:11:18 2005 | |
4 | @@ -779,6 +779,11 @@ | |
5 | GC_API GC_PTR GC_call_with_alloc_lock | |
6 | GC_PROTO((GC_fn_type fn, GC_PTR client_data)); | |
7 | ||
8 | +GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p)); | |
9 | + | |
10 | +/* Sets the leak handler to be called when an object is leaked. */ | |
11 | +GC_API void GC_set_leak_handler(void (*lh)(void*, int)); | |
12 | + | |
13 | /* The following routines are primarily intended for use with a */ | |
14 | /* preprocessor which inserts calls to check C pointer arithmetic. */ | |
15 | /* They indicate failure by invoking the corresponding _print_proc. */ | |
16 | diff -rbud gc6.5/reclaim.c gc6.5.patched/reclaim.c | |
17 | --- gc6.5/reclaim.c Tue Nov 23 06:58:18 2004 | |
18 | +++ gc6.5.patched/reclaim.c Sat Jun 25 00:52:18 2005 | |
19 | @@ -36,6 +36,14 @@ | |
20 | ||
21 | GC_bool GC_have_errors = FALSE; | |
22 | ||
23 | +static void (*leak_handler)(void*, int); | |
24 | + | |
25 | +void | |
26 | +GC_set_leak_handler(void (*lh)(void*, int)) | |
27 | +{ | |
28 | + leak_handler = lh; | |
29 | +} | |
30 | + | |
31 | void GC_add_leaked(leaked) | |
32 | ptr_t leaked; | |
33 | { | |
34 | @@ -64,6 +72,12 @@ | |
35 | if (GC_debugging_started) GC_print_all_smashed(); | |
36 | for (i = 0; i < GC_n_leaked; ++i) { | |
37 | ptr_t p = GC_leaked[i]; | |
38 | + if (leak_handler) | |
39 | + { | |
40 | + leak_handler(GC_base(p), GC_size(GC_base(p))); | |
41 | + } | |
42 | + else | |
43 | + { | |
44 | if (HDR(p) -> hb_obj_kind == PTRFREE) { | |
45 | GC_err_printf0("Leaked atomic object at "); | |
46 | } else { | |
47 | @@ -71,6 +85,7 @@ | |
48 | } | |
49 | GC_print_heap_obj(p); | |
50 | GC_err_printf0("\n"); | |
51 | + } | |
52 | GC_free(p); | |
53 | GC_leaked[i] = 0; | |
54 | } |