Add an external method to disable leak detective temporarly
[strongswan.git] / src / libstrongswan / utils / leak_detective.h
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup leak_detective leak_detective
18 * @{ @ingroup utils
19 */
20
21 #ifndef LEAK_DETECTIVE_H_
22 #define LEAK_DETECTIVE_H_
23
24 typedef struct leak_detective_t leak_detective_t;
25
26 #include <library.h>
27
28 /**
29 * Leak detective finds leaks and bad frees using malloc hooks.
30 *
31 * Currently leaks are reported to stderr on destruction.
32 *
33 * @todo Build an API for leak detective, allowing leak enumeration, statistics
34 * and dynamic whitelisting.
35 */
36 struct leak_detective_t {
37
38 /**
39 * Report leaks to stderr.
40 *
41 * @param detailed TRUE to resolve line/filename of leak (slow)
42 */
43 void (*report)(leak_detective_t *this, bool detailed);
44
45 /**
46 * Report current memory usage to out.
47 *
48 * @param out target to write usage report to
49 */
50 void (*usage)(leak_detective_t *this, FILE *out);
51
52 /**
53 * Enable/disable leak detective hooks.
54 *
55 * @param TRUE to enable, FALSE to disable
56 * @return state active before calling set_state
57 */
58 bool (*set_state)(leak_detective_t *this, bool enabled);
59
60 /**
61 * Destroy a leak_detective instance.
62 */
63 void (*destroy)(leak_detective_t *this);
64 };
65
66 /**
67 * Create a leak_detective instance.
68 */
69 leak_detective_t *leak_detective_create();
70
71 #endif /** LEAK_DETECTIVE_H_ @}*/
72