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