heap: fix RtlHeapReAllocate()

Dimitrie O. Paun dpaun at rogers.com
Mon Nov 24 14:35:12 CST 2003


On November 24, 2003 03:14 pm, Alexandre Julliard wrote:
> The heap test really belongs in kernel, there's no reason to explicitly
> test the Rtl*Heap functions, the Heap* ones do the same thing.

Fine, here it is again:

ChangeLog
   RtlHeapReAllocate() should not allocate memory.
   Add small test to make sure it doesn't return.
   Don't import ntdll for tests, we need to load it dynamically.

Index: dlls/ntdll/heap.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/heap.c,v
retrieving revision 1.25
diff -u -r1.25 heap.c
--- dlls/ntdll/heap.c	10 Oct 2003 00:12:17 -0000	1.25
+++ dlls/ntdll/heap.c	20 Nov 2003 21:00:39 -0000
@@ -1231,11 +1231,11 @@
     HEAP *heapPtr;
     SUBHEAP *subheap;
 
-    if (!ptr) return RtlAllocateHeap( heap, flags, size );  /* FIXME: correct? */
+    if (!ptr) return NULL;
     if (!(heapPtr = HEAP_GetPtr( heap )))
     {
         set_status( STATUS_INVALID_HANDLE );
-        return FALSE;
+        return NULL;
     }
 
     /* Validate the parameters */
Index: dlls/ntdll/tests/Makefile.in
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/tests/Makefile.in,v
retrieving revision 1.9
diff -u -r1.9 Makefile.in
--- dlls/ntdll/tests/Makefile.in	8 May 2003 03:47:24 -0000	1.9
+++ dlls/ntdll/tests/Makefile.in	24 Nov 2003 20:29:19 -0000
@@ -3,7 +3,6 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = ntdll.dll
-IMPORTS   = ntdll
 
 CTESTS = \
 	env.c \
Index: dlls/kernel/tests/Makefile.in
===================================================================
RCS file: /var/cvs/wine/dlls/kernel/tests/Makefile.in,v
retrieving revision 1.11
diff -u -r1.11 Makefile.in
--- dlls/kernel/tests/Makefile.in	30 Oct 2003 23:24:12 -0000	1.11
+++ dlls/kernel/tests/Makefile.in	24 Nov 2003 20:29:43 -0000
@@ -17,6 +17,7 @@
 	file.c \
 	format_msg.c \
 	generated.c \
+	heap.c \
 	locale.c \
 	mailslot.c \
 	path.c \
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ dlls/kernel/tests/heap.c	2003-11-24 15:30:28.000000000 -0500
@@ -0,0 +1,44 @@
+/*
+ * Unit test suite for heap functions
+ *
+ * Copyright 2003 Dimitrie O. Paun
+ *
+ * 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 <stdlib.h>
+
+#include "ntstatus.h"
+#include "windef.h"
+#include "winbase.h"
+#include "wine/test.h"
+#include "winnt.h"
+#include "winnls.h"
+#include "winreg.h"
+#include "winternl.h"
+
+static void test_realloc( void )
+{
+    void *mem = NULL;
+
+    mem = HeapReAlloc(GetProcessHeap(), 0, mem, 10);
+    ok(mem == NULL, "memory allocated");
+}
+
+START_TEST(heap)
+{
+    test_realloc();
+}


-- 
Dimi.




More information about the wine-devel mailing list