]> git.lyx.org Git - lyx.git/blob - development/Win32/vld/src/vldheap.h
Add support for glue length in parskip (#12867)
[lyx.git] / development / Win32 / vld / src / vldheap.h
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 //  Visual Leak Detector - Internal C++ Heap Management Definitions
4 //  Copyright (c) 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 #pragma once
25
26 #ifndef VLDBUILD
27 #error \
28 "This header should only be included by Visual Leak Detector when building it from source. \
29 Applications should never include this header."
30 #endif
31
32 #include <windows.h>
33
34 #define GAPSIZE 4
35
36 // Memory block header structure used internally by the debug CRT. All blocks
37 // allocated by the CRT are allocated from the CRT heap and, in debug mode, they
38 // have this header prepended to them (there's also a trailer appended at the
39 // end, but we're not interested in that).
40 typedef struct crtdbgblockheader_s
41 {
42     struct crtblockheader_s *next;          // Pointer to the next block in the list of blocks allocated from the CRT heap.
43     struct crtblockheader_s *prev;          // Pointer to the previous block in the list of blocks allocated from the CRT heap.
44     char                    *file;          // Source file where this block was allocated.
45     int                      line;          // Line of code, within the above file, where this block was allocated.
46 #ifdef _WIN64
47     int                      use;           // This block's "use type": see below.
48     size_t                   size;          // Size of the data portion of the block.
49 #else
50     size_t                   size;          // Size of the data portion of the block.
51     int                      use;           // This block's "use type":
52 #endif // _WIN64
53 #define CRT_USE_FREE     0                  //   This block has been freed.
54 #define CRT_USE_NORMAL   1                  //   This is a normal (user) block.
55 #define CRT_USE_INTERNAL 2                  //   This block is used internally by the CRT.
56 #define CRT_USE_IGNORE   3                  //   This block is a specially tagged block that is ignored during some debug error checking.
57 #define CRT_USE_CLIENT   4                  //   This block is a specially tagged block with special use defined by the user application.
58     long                     request;       // This block's "request" number. Basically a serial number.
59     unsigned char            gap [GAPSIZE]; // No-man's land buffer zone, for buffer overrun/underrun checking.
60 } crtdbgblockheader_t;
61
62 // Macro to strip off any sub-type information stored in a block's "use type".
63 #define CRT_USE_TYPE(use) (use & 0xFFFF)
64
65 // Memory block header structure used internally by VLD. All internally
66 // allocated blocks are allocated from VLD's private heap and have this header
67 // prepended to them.
68 typedef struct vldblockheader_s
69 {
70     struct vldblockheader_s *next;          // Pointer to the next block in the list of internally allocated blocks.
71     struct vldblockheader_s *prev;          // Pointer to the preceding block in the list of internally allocated blocks.
72     const char              *file;          // Name of the file where this block was allocated.
73     int                      line;          // Line number within the above file where this block was allocated.
74     size_t                   size;          // The size of this memory block, not including this header.
75     SIZE_T                   serialnumber;  // Each block is assigned a unique serial number, starting from zero.
76 } vldblockheader_t;
77
78 // Data-to-Header and Header-to-Data conversion
79 #define CRTDBGBLOCKHEADER(d) (crtdbgblockheader_t*)(((PBYTE)d) - sizeof(crtdbgblockheader_t))
80 #define CRTDBGBLOCKDATA(h) (LPVOID)(((PBYTE)h) + sizeof(crtdbgblockheader_t))
81 #define VLDBLOCKHEADER(d) (vldblockheader_t*)(((PBYTE)d) - sizeof(vldblockheader_t))
82 #define VLDBLOCKDATA(h) (LPVOID)(((PBYTE)h) + sizeof(vldblockheader_t))
83
84 // new and delete operators for allocating from VLD's private heap.
85 void operator delete (void *block);
86 void operator delete [] (void *block);
87 void operator delete (void *block, const char *file, int line);
88 void operator delete [] (void *block, const char *file, int line);
89 void* operator new (size_t size, const char *file, int line);
90 void* operator new [] (size_t size, const char *file, int line);
91
92 // All calls to the new operator from within VLD are mapped to the version of
93 // new that allocates from VLD's private heap.
94 #define new new(__FILE__, __LINE__)