Implemented the debug version of operator new (C++).

Patrik Stridvall ps at leissner.se
Mon May 17 14:51:00 CDT 2004


*** msvcrtd

* configure.ac,
  dlls/msvcrtd/Makefile.in,
  dlls/msvcrtd/debug.c,
  dlls/msvcrtd/msvcrtd.spec,
  dlls/msvcrtd/tests/.cvsignore,
  dlls/msvcrtd/tests/Makefile.in,
  dlls/msvcrtd/tests/debug.c:
Implemented the debug version of operator new (C++).

---8<---

Index: wine/configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.273
diff -u -u -r1.273 configure.ac
--- wine/configure.ac	14 May 2004 22:24:48 -0000	1.273
+++ wine/configure.ac	17 May 2004 17:27:39 -0000
@@ -1579,6 +1579,7 @@
 dlls/msvcrt20/Makefile
 dlls/msvcrt40/Makefile
 dlls/msvcrtd/Makefile
+dlls/msvcrtd/tests/Makefile
 dlls/msvidc32/Makefile
 dlls/msvideo/Makefile
 dlls/mswsock/Makefile
Index: wine/dlls/msvcrtd/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/msvcrtd/Makefile.in,v
retrieving revision 1.2
diff -u -u -r1.2 Makefile.in
--- wine/dlls/msvcrtd/Makefile.in	11 Oct 2003 01:09:18 -0000	1.2
+++ wine/dlls/msvcrtd/Makefile.in	17 May 2004 17:27:41 -0000
@@ -3,10 +3,12 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msvcrtd.dll
-IMPORTS   = msvcrt
+IMPORTS   = msvcrt kernel32
 
 C_SRCS = \
 	debug.c
+
+SUBDIRS = tests
 
 @MAKE_DLL_RULES@
 
Index: wine/dlls/msvcrtd/debug.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrtd/debug.c,v
retrieving revision 1.2
diff -u -u -r1.2 debug.c
--- wine/dlls/msvcrtd/debug.c	13 Jan 2004 05:37:47 -0000	1.2
+++ wine/dlls/msvcrtd/debug.c	17 May 2004 17:27:41 -0000
@@ -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 at 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 @@
 /*********************************************************************
  *		_CrtSetReportHook (MSVCRTD.@)
  */
-void *_CrtSetReportHook()
+void *_CrtSetReportHook(void *reportHook)
 {
     return NULL;
 }
@@ -47,7 +70,7 @@
 /*********************************************************************
  *		_CrtSetReportMode (MSVCRTD.@)
  */
-int _CrtSetReportMode()
+int _CrtSetReportMode(int reportType, int reportMode)
 {
     return 0;
 }
@@ -77,7 +100,8 @@
 /*********************************************************************
  *		_CrtDbgReport (MSVCRTD.@)
  */
-int _CrtDbgReport()
+int _CrtDbgReport(int reportType, const char *filename, int linenumber,
+		  const char *moduleName, const char *format, ...)
 {
     return 0;
 }
Index: wine/dlls/msvcrtd/msvcrtd.spec
===================================================================
RCS file: /home/wine/wine/dlls/msvcrtd/msvcrtd.spec,v
retrieving revision 1.9
diff -u -u -r1.9 msvcrtd.spec
--- wine/dlls/msvcrtd/msvcrtd.spec	12 May 2004 23:22:36 -0000	1.9
+++ wine/dlls/msvcrtd/msvcrtd.spec	17 May 2004 17:27:42 -0000
@@ -16,7 +16,7 @@
 @ cdecl -i386 ??1exception@@UAE at XZ() msvcrt.??1exception@@UAE at XZ
 @ cdecl -i386 ??1type_info@@UAE at XZ() msvcrt.??1type_info@@UAE at XZ
 @ cdecl ??2 at YAPAXI@Z(long) msvcrt.??2 at YAPAXI@Z
-@ cdecl ??2 at YAPAXIHPBDH@Z(long) msvcrt.??2 at YAPAXIHPBDH@Z
+@ cdecl ??2 at YAPAXIHPBDH@Z(long long str long) MSVCRTD_operator_new_dbg
 @ cdecl ??3 at YAXPAX@Z(ptr) msvcrt.??3 at YAXPAX@Z
 @ cdecl -i386 ??4__non_rtti_object@@QAEAAV0 at ABV0@@Z(ptr) msvcrt.??4__non_rtti_object@@QAEAAV0 at ABV0@@Z
 @ cdecl -i386 ??4bad_cast@@QAEAAV0 at ABV0@@Z(ptr) msvcrt.??4bad_cast@@QAEAAV0 at 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
--- /dev/null	2004-05-11 00:33:36.000000000 +0200
+++ wine/dlls/msvcrtd/tests/.cvsignore	2004-05-13 17:27:29.000000000 +0200
@@ -0,0 +1,2 @@
+Makefile
+debug.ok
--- /dev/null	2004-05-11 00:33:36.000000000 +0200
+++ wine/dlls/msvcrtd/tests/Makefile.in	2004-05-13 16:28:31.000000000 +0200
@@ -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
+
+ at MAKE_TEST_RULES@
+
+### Dependencies:
--- /dev/null	2004-05-11 00:33:36.000000000 +0200
+++ wine/dlls/msvcrtd/tests/debug.c	2004-05-14 10:47:51.000000000 +0200
@@ -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 at 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();
+}




More information about the wine-patches mailing list