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