Commit 6de20f33 authored by Saulius Krasuckas's avatar Saulius Krasuckas Committed by Alexandre Julliard

- Declare implemented functions inside #ifndef _DEBUG block.

- Make MSVCRTD_operator_new_dbg recognize types of memory blocks.
parent 84bb3722
...@@ -5,6 +5,7 @@ VPATH = @srcdir@ ...@@ -5,6 +5,7 @@ VPATH = @srcdir@
MODULE = msvcrtd.dll MODULE = msvcrtd.dll
IMPORTLIB = libmsvcrtd.$(IMPLIBEXT) IMPORTLIB = libmsvcrtd.$(IMPLIBEXT)
IMPORTS = msvcrt kernel32 IMPORTS = msvcrt kernel32
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
C_SRCS = \ C_SRCS = \
debug.c debug.c
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include "winbase.h" #include "winbase.h"
#define _DEBUG
#include "crtdbg.h"
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
int _crtAssertBusy = -1; int _crtAssertBusy = -1;
...@@ -39,10 +42,30 @@ void *MSVCRTD_operator_new_dbg( ...@@ -39,10 +42,30 @@ void *MSVCRTD_operator_new_dbg(
const char *szFileName, const char *szFileName,
int nLine) int nLine)
{ {
void *retval = HeapAlloc(GetProcessHeap(), 0, nSize); void *retval = NULL;
TRACE("(%lu, %d, '%s', %d) returning %p\n", nSize, nBlockUse, szFileName, nLine, retval); TRACE("(%lu, %d, '%s', %d) returning %p\n", nSize, nBlockUse, szFileName, nLine, retval);
switch(_BLOCK_TYPE(nBlockUse))
{
case _NORMAL_BLOCK:
break;
case _CLIENT_BLOCK:
FIXME("Unimplemented case for nBlockUse = _CLIENT_BLOCK\n");
return NULL;
case _FREE_BLOCK:
FIXME("Native code throws an exception here\n");
case _CRT_BLOCK:
case _IGNORE_BLOCK:
ERR("Not allowed nBlockUse value: %d\n", _BLOCK_TYPE(nBlockUse));
return NULL;
default:
ERR("Unknown nBlockUse value: %d\n", _BLOCK_TYPE(nBlockUse));
return NULL;
}
retval = HeapAlloc(GetProcessHeap(), 0, nSize);
if (!retval) if (!retval)
_callnewh(nSize); _callnewh(nSize);
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "winbase.h" #include "winbase.h"
#include "winnt.h" #include "winnt.h"
#include "crtdbg.h"
#include "wine/test.h" #include "wine/test.h"
/**********************************************************************/ /**********************************************************************/
...@@ -55,7 +57,7 @@ static void test_new(void) ...@@ -55,7 +57,7 @@ static void test_new(void)
{ {
void *mem; void *mem;
mem = pMSVCRTD_operator_new_dbg(42, 0, __FILE__, __LINE__); mem = pMSVCRTD_operator_new_dbg(42, _NORMAL_BLOCK, __FILE__, __LINE__);
ok(mem != NULL, "memory not allocated\n"); ok(mem != NULL, "memory not allocated\n");
} }
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#define _CLIENT_BLOCK 4 #define _CLIENT_BLOCK 4
#define _MAX_BLOCKS 5 #define _MAX_BLOCKS 5
#define _BLOCK_TYPE(block) (block & 0xFFFF)
#define _BLOCK_SUBTYPE(block) (block >> 16 & 0xFFFF)
typedef struct _CrtMemState typedef struct _CrtMemState
{ {
...@@ -56,6 +58,14 @@ typedef struct _CrtMemState ...@@ -56,6 +58,14 @@ typedef struct _CrtMemState
#define _ASSERTE(expr) ((void)0) #define _ASSERTE(expr) ((void)0)
#define _CrtDbgBreak() ((void)0) #define _CrtDbgBreak() ((void)0)
#define _CrtCheckMemory() ((int)1)
#define _CrtDbgReport(...) ((int)0)
#define _CrtDumpMemoryLeaks() ((int)0)
#define _CrtSetBreakAlloc(a) ((long)0)
#define _CrtSetDbgFlag(f) ((int)0)
#define _CrtSetDumpClient(f) ((void)0)
#define _CrtSetReportMode(t,m) ((int)0)
#else /* _DEBUG */ #else /* _DEBUG */
#include <assert.h> #include <assert.h>
...@@ -67,12 +77,22 @@ typedef struct _CrtMemState ...@@ -67,12 +77,22 @@ typedef struct _CrtMemState
#define _CrtDbgBreak() ((void)0) #define _CrtDbgBreak() ((void)0)
#endif #endif
extern int _crtAssertBusy;
extern int _crtBreakAlloc;
extern int _crtDbgFlag;
int _CrtCheckMemory();
int _CrtDbgReport(int reportType, const char *filename, int linenumber,
const char *moduleName, const char *format, ...);
int _CrtDumpMemoryLeaks();
int _CrtSetBreakAlloc(int new);
int _CrtSetDbgFlag(int new);
void *_CrtSetDumpClient(void *dumpClient);
int _CrtSetReportMode(int reportType, int reportMode);
#endif /* _DEBUG */ #endif /* _DEBUG */
#define _CrtCheckMemory() ((int)1)
#define _CrtDbgReport(...) ((int)0)
#define _CrtDoForAllClientObjects(f,c) ((void)0) #define _CrtDoForAllClientObjects(f,c) ((void)0)
#define _CrtDumpMemoryLeaks() ((int)0)
#define _CrtIsMemoryBlock(p,s,r,f,l) ((int)1) #define _CrtIsMemoryBlock(p,s,r,f,l) ((int)1)
#define _CrtIsValidHeapPointer(p) ((int)1) #define _CrtIsValidHeapPointer(p) ((int)1)
#define _CrtIsValidPointer(p,s,a) ((int)1) #define _CrtIsValidPointer(p,s,a) ((int)1)
...@@ -81,10 +101,6 @@ typedef struct _CrtMemState ...@@ -81,10 +101,6 @@ typedef struct _CrtMemState
#define _CrtMemDumpAllObjectsSince(s) ((void)0) #define _CrtMemDumpAllObjectsSince(s) ((void)0)
#define _CrtMemDumpStatistics(s) ((void)0) #define _CrtMemDumpStatistics(s) ((void)0)
#define _CrtSetAllocHook(f) ((void)0) #define _CrtSetAllocHook(f) ((void)0)
#define _CrtSetBreakAlloc(a) ((long)0)
#define _CrtSetDbgFlag(f) ((int)0)
#define _CrtSetDumpClient(f) ((void)0)
#define _CrtSetReportMode(t,m) ((int)0)
#define _RPT0(t,m) #define _RPT0(t,m)
#define _RPT1(t,m,p1) #define _RPT1(t,m,p1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment