1 /*****************************************************************
2 |
3 | Platinum - Leaks
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
13 |
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
21 |
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
26 |
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
32 |
33 ****************************************************************/
34
35 /*----------------------------------------------------------------------
36 | includes
37 +---------------------------------------------------------------------*/
38 #include "PltLeaks.h"
39
40 #if defined(WIN32)
41 #include <crtdbg.h>
42 #include <stdio.h>
43 #include "string.h"
44
45 /*----------------------------------------------------------------------
46 | PLT_Leak_AllocHook
47 +---------------------------------------------------------------------*/
PLT_Leak_AllocHook(int alloc_type,void * user_data,size_t size,int block_type,long request_number,const unsigned char * filename,int line_number)48 int PLT_Leak_AllocHook(int alloc_type,
49 void* user_data,
50 size_t size,
51 int block_type,
52 long request_number,
53 const unsigned char* filename,
54 int line_number)
55 {
56 (void)alloc_type;
57 (void)user_data;
58 (void)size;
59 (void)block_type;
60 (void)request_number;
61 (void)line_number;
62 (void)filename;
63 /*
64 * if (request_number == 34556)
65 * return 2;
66 *
67 */
68 return 1;
69 }
70
71 /*----------------------------------------------------------------------
72 | PLT_Leak_Enable
73 +---------------------------------------------------------------------*/
74 void
PLT_Leak_Enable(void)75 PLT_Leak_Enable(void)
76 {
77 #if defined(_DEBUG)
78 /*
79 * If you want VC to dump file name and line number of leaking resource
80 * use #define _CRTDBG_MAP_ALLOC in suspected file (project)
81 * and #include "crtdbg.h" in suspected file
82 */
83 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF |
84 _CRTDBG_CHECK_ALWAYS_DF |
85 _CRTDBG_LEAK_CHECK_DF);
86
87 _CrtSetAllocHook(PLT_Leak_AllocHook );
88
89 #endif
90 }
91 #else
92 /*----------------------------------------------------------------------
93 | PLT_Leak_Enable
94 +---------------------------------------------------------------------*/
95 void
PLT_Leak_Enable(void)96 PLT_Leak_Enable(void)
97 {
98 }
99 #endif
100