-
Notifications
You must be signed in to change notification settings - Fork 399
/
vldapi.cpp
68 lines (59 loc) · 2.46 KB
/
vldapi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
////////////////////////////////////////////////////////////////////////////////
//
// Visual Leak Detector - Exported APIs
// Copyright (c) 2005-2006 Dan Moulding
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// See COPYING.txt for the full terms of the GNU Lesser General Public License.
//
////////////////////////////////////////////////////////////////////////////////
#define VLDBUILD // Declares that we are building Visual Leak Detector.
#include "vldint.h" // Provides access to the Visual Leak Detector internals.
#include "vldheap.h" // Provides internal new and delete operators.
// Imported global variables.
extern VisualLeakDetector vld;
////////////////////////////////////////////////////////////////////////////////
//
// Visual Leak Detector APIs - see vldapi.h for each function's details.
//
extern "C" __declspec(dllexport) void VLDDisable ()
{
tls_t *tls;
if (vld.m_options & VLD_OPT_VLDOFF) {
// VLD has been turned off.
return;
}
// Disable memory leak detection for the current thread. There are two flags
// because if neither flag is set, it means that we are in the default or
// "starting" state, which could be either enabled or disabled depending on
// the configuration.
tls = vld.gettls();
tls->flags &= ~VLD_TLS_ENABLED;
tls->flags |= VLD_TLS_DISABLED;
}
extern "C" __declspec(dllexport) void VLDEnable ()
{
tls_t *tls;
if (vld.m_options & VLD_OPT_VLDOFF) {
// VLD has been turned off.
return;
}
// Enable memory leak detection for the current thread.
tls = vld.gettls();
tls->flags &= ~VLD_TLS_DISABLED;
tls->flags |= VLD_TLS_ENABLED;
vld.m_status &= ~VLD_STATUS_NEVER_ENABLED;
}