]> git.lyx.org Git - lyx.git/blob - development/Win32/vld/src/vldapi.cpp
Add support for glue length in parskip (#12867)
[lyx.git] / development / Win32 / vld / src / vldapi.cpp
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 //  Visual Leak Detector - Exported APIs
4 //  Copyright (c) 2005-2006 Dan Moulding
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See COPYING.txt for the full terms of the GNU Lesser General Public License.
21 //
22 ////////////////////////////////////////////////////////////////////////////////
23
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.
27
28 // Imported global variables.
29 extern VisualLeakDetector vld;
30
31 ////////////////////////////////////////////////////////////////////////////////
32 //
33 //  Visual Leak Detector APIs - see vldapi.h for each function's details.
34 //
35
36 extern "C" __declspec(dllexport) void VLDDisable ()
37 {
38     tls_t *tls;
39
40     if (vld.m_options & VLD_OPT_VLDOFF) {
41         // VLD has been turned off.
42         return;
43     }
44
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
48     // the configuration.
49     tls = vld.gettls();
50     tls->flags &= ~VLD_TLS_ENABLED;
51     tls->flags |= VLD_TLS_DISABLED;
52 }
53
54 extern "C" __declspec(dllexport) void VLDEnable ()
55 {
56     tls_t *tls;
57
58     if (vld.m_options & VLD_OPT_VLDOFF) {
59         // VLD has been turned off.
60         return;
61     }
62
63     // Enable memory leak detection for the current thread.
64     tls = vld.gettls();
65     tls->flags &= ~VLD_TLS_DISABLED;
66     tls->flags |= VLD_TLS_ENABLED;
67     vld.m_status &= ~VLD_STATUS_NEVER_ENABLED;
68 }