implement IAUTH client code to query a separate server before allowing
[ircu2.10.12-pk.git] / doc / debug_memleak_gc.patch
1 The following patch has to be applied to Boehm gc6.0 from
2 http://www.hpl.hp.com/personal/Hans_Boehm/gc/
3 and you need to configure ircd with --with-leak-detect=path-to-gc6.0/.lib/
4
5 diff -ru -x *.a -x *.so* -x *.o -x *.lo -x *.log -x *.*~ gc6.0/include/gc.h gc6.0-ircu/include/gc.h
6 --- gc6.0/include/gc.h  Tue Jul 24 05:02:02 2001
7 +++ gc6.0-ircu/include/gc.h     Sat Jun 29 21:04:40 2002
8 @@ -722,6 +722,11 @@
9  GC_API GC_PTR GC_call_with_alloc_lock
10                 GC_PROTO((GC_fn_type fn, GC_PTR client_data));
11  
12 +GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p));
13 +
14 +/* Sets the leak handler to be called when an object is leaked. */
15 +GC_API void GC_set_leak_handler(void (*lh)(void*, int));
16 +
17  /* The following routines are primarily intended for use with a        */
18  /* preprocessor which inserts calls to check C pointer arithmetic.     */
19  
20 diff -ru -x *.a -x *.so* -x *.o -x *.lo -x *.log -x *.*~ gc6.0/reclaim.c gc6.0-ircu/reclaim.c
21 --- gc6.0/reclaim.c     Tue Jun 12 10:21:28 2001
22 +++ gc6.0-ircu/reclaim.c        Sat Jun 29 21:00:16 2002
23 @@ -27,24 +27,23 @@
24         /* nonzero.                                                     */
25  #endif /* PARALLEL_MARK */
26  
27 -static void report_leak(p, sz)
28 -ptr_t p;
29 -word sz;
30 +void (*leak_handler)(void*, int);
31 +
32 +void
33 +GC_set_leak_handler(void (*lh)(void*, int))
34 +{
35 +  leak_handler = lh;
36 +}
37 +
38 +static void
39 +report_leak(ptr_t p, word sz)
40  {
41 -    if (HDR(p) -> hb_obj_kind == PTRFREE) {
42 -        GC_err_printf0("Leaked atomic object at ");
43 -    } else {
44 -        GC_err_printf0("Leaked composite object at ");
45 -    }
46 -    GC_print_heap_obj(p);
47 -    GC_err_printf0("\n");
48 +  if (leak_handler != NULL)
49 +    leak_handler((void*)p, (int)sz);
50  }
51  
52 -#   define FOUND_FREE(hblk, word_no) \
53 -      { \
54 -         report_leak((ptr_t)hblk + WORDS_TO_BYTES(word_no), \
55 -                    HDR(hblk) -> hb_sz); \
56 -      }
57 +#define FOUND_FREE(hblk, word_no) \
58 +  report_leak((ptr_t)hblk + WORDS_TO_BYTES(word_no), HDR(hblk)->hb_sz);
59  
60  /*
61   * reclaim phase