mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 12:20:07 +00:00
Implemented the debug version of operator new (C++).
This commit is contained in:
parent
8f14eb0eb6
commit
5c4420fc4c
@ -1580,6 +1580,7 @@ dlls/msvcrt/tests/Makefile
|
||||
dlls/msvcrt20/Makefile
|
||||
dlls/msvcrt40/Makefile
|
||||
dlls/msvcrtd/Makefile
|
||||
dlls/msvcrtd/tests/Makefile
|
||||
dlls/msvidc32/Makefile
|
||||
dlls/msvideo/Makefile
|
||||
dlls/mswsock/Makefile
|
||||
|
@ -3,11 +3,13 @@ TOPOBJDIR = ../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = msvcrtd.dll
|
||||
IMPORTS = msvcrt
|
||||
IMPORTS = msvcrt kernel32
|
||||
|
||||
C_SRCS = \
|
||||
debug.c
|
||||
|
||||
SUBDIRS = tests
|
||||
|
||||
@MAKE_DLL_RULES@
|
||||
|
||||
### Dependencies:
|
||||
|
@ -20,16 +20,39 @@
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
#include "winbase.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
||||
|
||||
int _crtAssertBusy = -1;
|
||||
int _crtBreakAlloc = -1;
|
||||
int _crtDbgFlag = 0;
|
||||
|
||||
extern int _callnewh(unsigned long);
|
||||
|
||||
/*********************************************************************
|
||||
* ??2@YAPAXIHPBDH@Z (MSVCRTD.@)
|
||||
*/
|
||||
void *MSVCRTD_operator_new_dbg(
|
||||
unsigned long nSize,
|
||||
int nBlockUse,
|
||||
const char *szFileName,
|
||||
int nLine)
|
||||
{
|
||||
void *retval = HeapAlloc(GetProcessHeap(), 0, nSize);
|
||||
|
||||
TRACE("(%lu, %d, '%s', %d) returning %p\n", nSize, nBlockUse, szFileName, nLine, retval);
|
||||
|
||||
if (!retval)
|
||||
_callnewh(nSize);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _CrtSetDumpClient (MSVCRTD.@)
|
||||
*/
|
||||
void *_CrtSetDumpClient()
|
||||
void *_CrtSetDumpClient(void *dumpClient)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -38,7 +61,7 @@ void *_CrtSetDumpClient()
|
||||
/*********************************************************************
|
||||
* _CrtSetReportHook (MSVCRTD.@)
|
||||
*/
|
||||
void *_CrtSetReportHook()
|
||||
void *_CrtSetReportHook(void *reportHook)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -47,7 +70,7 @@ void *_CrtSetReportHook()
|
||||
/*********************************************************************
|
||||
* _CrtSetReportMode (MSVCRTD.@)
|
||||
*/
|
||||
int _CrtSetReportMode()
|
||||
int _CrtSetReportMode(int reportType, int reportMode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -77,7 +100,8 @@ int _CrtSetDbgFlag(int new)
|
||||
/*********************************************************************
|
||||
* _CrtDbgReport (MSVCRTD.@)
|
||||
*/
|
||||
int _CrtDbgReport()
|
||||
int _CrtDbgReport(int reportType, const char *filename, int linenumber,
|
||||
const char *moduleName, const char *format, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
@ cdecl -i386 ??1exception@@UAE@XZ() msvcrt.??1exception@@UAE@XZ
|
||||
@ cdecl -i386 ??1type_info@@UAE@XZ() msvcrt.??1type_info@@UAE@XZ
|
||||
@ cdecl ??2@YAPAXI@Z(long) msvcrt.??2@YAPAXI@Z
|
||||
@ cdecl ??2@YAPAXIHPBDH@Z(long) msvcrt.??2@YAPAXIHPBDH@Z
|
||||
@ cdecl ??2@YAPAXIHPBDH@Z(long long str long) MSVCRTD_operator_new_dbg
|
||||
@ cdecl ??3@YAXPAX@Z(ptr) msvcrt.??3@YAXPAX@Z
|
||||
@ cdecl -i386 ??4__non_rtti_object@@QAEAAV0@ABV0@@Z(ptr) msvcrt.??4__non_rtti_object@@QAEAAV0@ABV0@@Z
|
||||
@ cdecl -i386 ??4bad_cast@@QAEAAV0@ABV0@@Z(ptr) msvcrt.??4bad_cast@@QAEAAV0@ABV0@@Z
|
||||
@ -68,7 +68,7 @@
|
||||
@ cdecl _CItanh() msvcrt._CItanh
|
||||
@ stub _CrtCheckMemory
|
||||
@ stub _CrtDbgBreak
|
||||
@ cdecl _CrtDbgReport(long ptr long ptr ptr)
|
||||
@ varargs _CrtDbgReport(long ptr long ptr ptr)
|
||||
@ stub _CrtDoForAllClientObjects
|
||||
@ cdecl _CrtDumpMemoryLeaks()
|
||||
@ stub _CrtIsMemoryBlock
|
||||
@ -85,7 +85,7 @@
|
||||
@ cdecl _CrtSetDumpClient(ptr)
|
||||
@ stub _CrtSetReportFile
|
||||
@ cdecl _CrtSetReportHook(ptr)
|
||||
@ cdecl _CrtSetReportMode(long)
|
||||
@ cdecl _CrtSetReportMode(long long)
|
||||
@ cdecl _CxxThrowException(long long) msvcrt._CxxThrowException
|
||||
@ cdecl -i386 -norelay _EH_prolog() msvcrt._EH_prolog
|
||||
@ cdecl _Getdays() msvcrt._Getdays
|
||||
|
3
dlls/msvcrtd/tests/.cvsignore
Normal file
3
dlls/msvcrtd/tests/.cvsignore
Normal file
@ -0,0 +1,3 @@
|
||||
Makefile
|
||||
debug.ok
|
||||
testlist.c
|
14
dlls/msvcrtd/tests/Makefile.in
Normal file
14
dlls/msvcrtd/tests/Makefile.in
Normal file
@ -0,0 +1,14 @@
|
||||
TOPSRCDIR = @top_srcdir@
|
||||
TOPOBJDIR = ../../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = msvcrtd.dll
|
||||
IMPORTS = msvcrtd
|
||||
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
|
||||
|
||||
CTESTS = \
|
||||
debug.c
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
### Dependencies:
|
70
dlls/msvcrtd/tests/debug.c
Normal file
70
dlls/msvcrtd/tests/debug.c
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Unit test suite for debug functions.
|
||||
*
|
||||
* Copyright 2004 Patrik Stridvall
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnt.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
static void * (*pMSVCRTD_operator_new_dbg)(unsigned long, int, const char *, int) = NULL;
|
||||
|
||||
/* Some exports are only available in later versions */
|
||||
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hModule,y)
|
||||
#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
|
||||
|
||||
int init_functions(void)
|
||||
{
|
||||
HMODULE hModule = LoadLibraryA("msvcrtd.dll");
|
||||
ok(hModule != NULL, "LoadLibraryA failed\n");
|
||||
|
||||
if (!hModule)
|
||||
return FALSE;
|
||||
|
||||
SET(pMSVCRTD_operator_new_dbg, "??2@YAPAXIHPBDH@Z");
|
||||
if (pMSVCRTD_operator_new_dbg == NULL)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
void test_new(void)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
mem = pMSVCRTD_operator_new_dbg(42, 0, __FILE__, __LINE__);
|
||||
ok(mem != NULL, "memory not allocated\n");
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
START_TEST(debug)
|
||||
{
|
||||
if (!init_functions())
|
||||
return;
|
||||
|
||||
test_new();
|
||||
}
|
Loading…
Reference in New Issue
Block a user