- Declare implemented functions inside #ifndef _DEBUG block.

- Make MSVCRTD_operator_new_dbg recognize types of memory blocks.
This commit is contained in:
Saulius Krasuckas 2005-07-21 10:34:08 +00:00 committed by Alexandre Julliard
parent 84bb372239
commit 6de20f33ae
4 changed files with 51 additions and 9 deletions

View File

@ -5,6 +5,7 @@ VPATH = @srcdir@
MODULE = msvcrtd.dll
IMPORTLIB = libmsvcrtd.$(IMPLIBEXT)
IMPORTS = msvcrt kernel32
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
C_SRCS = \
debug.c

View File

@ -22,6 +22,9 @@
#include "winbase.h"
#define _DEBUG
#include "crtdbg.h"
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
int _crtAssertBusy = -1;
@ -39,10 +42,30 @@ void *MSVCRTD_operator_new_dbg(
const char *szFileName,
int nLine)
{
void *retval = HeapAlloc(GetProcessHeap(), 0, nSize);
void *retval = NULL;
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)
_callnewh(nSize);

View File

@ -24,6 +24,8 @@
#include "winbase.h"
#include "winnt.h"
#include "crtdbg.h"
#include "wine/test.h"
/**********************************************************************/
@ -55,7 +57,7 @@ static void test_new(void)
{
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");
}

View File

@ -39,6 +39,8 @@
#define _CLIENT_BLOCK 4
#define _MAX_BLOCKS 5
#define _BLOCK_TYPE(block) (block & 0xFFFF)
#define _BLOCK_SUBTYPE(block) (block >> 16 & 0xFFFF)
typedef struct _CrtMemState
{
@ -56,6 +58,14 @@ typedef struct _CrtMemState
#define _ASSERTE(expr) ((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 */
#include <assert.h>
@ -67,12 +77,22 @@ typedef struct _CrtMemState
#define _CrtDbgBreak() ((void)0)
#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 */
#define _CrtCheckMemory() ((int)1)
#define _CrtDbgReport(...) ((int)0)
#define _CrtDoForAllClientObjects(f,c) ((void)0)
#define _CrtDumpMemoryLeaks() ((int)0)
#define _CrtIsMemoryBlock(p,s,r,f,l) ((int)1)
#define _CrtIsValidHeapPointer(p) ((int)1)
#define _CrtIsValidPointer(p,s,a) ((int)1)
@ -81,10 +101,6 @@ typedef struct _CrtMemState
#define _CrtMemDumpAllObjectsSince(s) ((void)0)
#define _CrtMemDumpStatistics(s) ((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 _RPT1(t,m,p1)