]> git.ipfire.org Git - thirdparty/squid.git/blob - src/LeakFinder.h
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / LeakFinder.h
1 /*
2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_LEAKFINDER_H
10 #define SQUID_LEAKFINDER_H
11
12 #if USE_LEAKFINDER
13
14 #include "hash.h"
15
16 #define leakAdd(p,l) if (l) l->addSome(p,__FILE__,__LINE__)
17 #define leakTouch(p,l) if (l) l->touch(p,__FILE__,__LINE__)
18 #define leakFree(p,l) if (l) l->freeSome(p,__FILE__,__LINE__)
19
20 class LeakFinderPtr : public hash_link
21 {
22
23 public:
24 LeakFinderPtr(void *, const char *, const int);
25 const char *file;
26 int line;
27 time_t when;
28 };
29
30 class LeakFinder
31 {
32
33 public:
34 LeakFinder();
35 ~LeakFinder();
36
37 void *addSome(void *, const char *, const int);
38
39 void *touch(void *, const char *, const int);
40
41 void *freeSome(void *, const char *, const int);
42
43 void dump();
44
45 private:
46 static HASHCMP cmp;
47
48 static HASHHASH hash;
49
50 hash_table *table;
51
52 int count;
53
54 time_t last_dump;
55
56 };
57
58 #else /* USE_LEAKFINDER */
59
60 class LeakFinder {};
61
62 #define leakAdd(p,l) (void)0
63 #define leakTouch(p,l) (void)0
64 #define leakFree(p,l) (void)0
65 #endif /* USE_LEAKFINDER */
66
67 #endif /* SQUID_LEAKFINDER_H */
68