Update the address of the Free Software Foundation.
[wine] / dlls / msvcrtd / debug.c
1 /*
2  * msvcrtd.dll debugging code
3  *
4  * Copyright (C) 2003 Adam Gundy
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
21 #include "wine/debug.h"
22
23 #include "winbase.h"
24
25 #define  _DEBUG
26 #include "crtdbg.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
29
30 int _crtAssertBusy = -1;
31 int _crtBreakAlloc = -1;
32 int _crtDbgFlag = 0;
33
34 extern int _callnewh(unsigned long);
35
36 /*********************************************************************
37  *              ??2@YAPAXIHPBDH@Z (MSVCRTD.@)
38  */
39 void *MSVCRTD_operator_new_dbg(
40         unsigned long nSize,
41         int nBlockUse,
42         const char *szFileName,
43         int nLine)
44 {
45     void *retval = NULL;
46
47     TRACE("(%lu, %d, '%s', %d) returning %p\n", nSize, nBlockUse, szFileName, nLine, retval);
48
49     switch(_BLOCK_TYPE(nBlockUse))
50     {
51     case _NORMAL_BLOCK:
52         break;
53     case _CLIENT_BLOCK:
54         FIXME("Unimplemented case for nBlockUse = _CLIENT_BLOCK\n");
55         return NULL;
56     case _FREE_BLOCK:
57         FIXME("Native code throws an exception here\n");
58     case _CRT_BLOCK:
59     case _IGNORE_BLOCK:
60         ERR("Not allowed nBlockUse value: %d\n", _BLOCK_TYPE(nBlockUse));
61         return NULL;
62     default:
63         ERR("Unknown nBlockUse value: %d\n", _BLOCK_TYPE(nBlockUse));
64         return NULL;
65     }
66
67     retval = HeapAlloc(GetProcessHeap(), 0, nSize);
68
69     if (!retval)
70         _callnewh(nSize);
71
72     return retval;
73 }
74
75 /*********************************************************************
76  *              _CrtSetDumpClient (MSVCRTD.@)
77  */
78 void *_CrtSetDumpClient(void *dumpClient)
79 {
80     return NULL;
81 }
82
83
84 /*********************************************************************
85  *              _CrtSetReportHook (MSVCRTD.@)
86  */
87 void *_CrtSetReportHook(void *reportHook)
88 {
89     return NULL;
90 }
91
92
93 /*********************************************************************
94  *              _CrtSetReportMode (MSVCRTD.@)
95  */
96 int _CrtSetReportMode(int reportType, int reportMode)
97 {
98     return 0;
99 }
100
101
102 /*********************************************************************
103  *              _CrtSetBreakAlloc (MSVCRTD.@)
104  */
105 int _CrtSetBreakAlloc(int new)
106 {
107     int old = _crtBreakAlloc;
108     _crtBreakAlloc = new;
109     return old;
110 }
111
112 /*********************************************************************
113  *              _CrtSetDbgFlag (MSVCRTD.@)
114  */
115 int _CrtSetDbgFlag(int new)
116 {
117     int old = _crtDbgFlag;
118     _crtDbgFlag = new;
119     return old;
120 }
121
122
123 /*********************************************************************
124  *              _CrtDbgReport (MSVCRTD.@)
125  */
126 int _CrtDbgReport(int reportType, const char *filename, int linenumber,
127                   const char *moduleName, const char *format, ...)
128 {
129     return 0;
130 }
131
132 /*********************************************************************
133  *              _CrtDumpMemoryLeaks (MSVCRTD.@)
134  */
135 int _CrtDumpMemoryLeaks(void)
136 {
137     return 0;
138 }
139
140 /*********************************************************************
141  *              _CrtCheckMemory (MSVCRTD.@)
142  */
143 int _CrtCheckMemory(void)
144 {
145     /* Note: maybe we could call here our heap validating functions ? */
146     return TRUE;
147 }
148
149
150 /*********************************************************************
151  *              __p__crtAssertBusy (MSVCRTD.@)
152  */
153 int *__p__crtAssertBusy(void)
154 {
155     return &_crtAssertBusy;
156 }
157
158 /*********************************************************************
159  *              __p__crtBreakAlloc (MSVCRTD.@)
160  */
161 int *__p__crtBreakAlloc(void)
162 {
163     return &_crtBreakAlloc;
164 }
165
166 /*********************************************************************
167  *              __p__crtDbgFlag (MSVCRTD.@)
168  */
169 int *__p__crtDbgFlag(void)
170 {
171     return &_crtDbgFlag;
172 }