]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
ef57eb7b | 2 | * Copyright (C) 1996-2016 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
82f27590 | 9 | #ifndef SQUID_LEAKFINDER_H |
10 | #define SQUID_LEAKFINDER_H | |
11 | ||
12 | #if USE_LEAKFINDER | |
c38a2377 AJ |
13 | |
14 | #include "hash.h" | |
15 | ||
16 | #define leakAdd(p,l) if (l) l->addSome(p,__FILE__,__LINE__) | |
82f27590 | 17 | #define leakTouch(p,l) if (l) l->touch(p,__FILE__,__LINE__) |
c38a2377 | 18 | #define leakFree(p,l) if (l) l->freeSome(p,__FILE__,__LINE__) |
82f27590 | 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 | ||
c38a2377 | 37 | void *addSome(void *, const char *, const int); |
82f27590 | 38 | |
39 | void *touch(void *, const char *, const int); | |
40 | ||
c38a2377 | 41 | void *freeSome(void *, const char *, const int); |
82f27590 | 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 */ | |
f53969cc | 68 |