KERNEL/tests: respect 9x-ness of HeapAlloc
Saulius Krasuckas
saulius2 at ar.fi.lt
Mon Nov 7 18:31:30 CST 2005
* On Mon, 7 Nov 2005, Saulius Krasuckas wrote:
>
> + DWORD dwSizeAligned;
> + DWORD dwPageSizeKiB;
> + SYSTEM_INFO si;
> +
> + GetSystemInfo(&si);
> + dwPageSizeKiB = si.dwPageSize / 1024; /* 4 KiB */
> + dwSizeAligned = ((size - 1)/dwPageSizeKiB + 1) * dwPageSizeKiB;
> +
> + return max(dwSizeAligned, 3*dwPageSizeKiB); /* at least 12 KiB */
Ughmmm, well, I really don't know, why I considered this to be a right
way. It makes no sense to mix old code with a new wishes. (4 B != 4 KiB)
And I do not know, where does this constant value of 4 B come from.
Log message:
Saulius Krasuckas <saulius.krasuckas at ieee.org>
Take into account some alignment done by HeapAlloc() on Win9x.
Index: dlls/kernel/tests/heap.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/heap.c,v
retrieving revision 1.6
diff -p -u -r1.6 heap.c
--- dlls/kernel/tests/heap.c 11 Jul 2005 13:20:40 -0000 1.6
+++ dlls/kernel/tests/heap.c 7 Nov 2005 23:33:12 -0000
@@ -25,6 +25,18 @@
#include "winbase.h"
#include "wine/test.h"
+static SIZE_T resize_9x(SIZE_T size)
+{
+ DWORD dwSizeAligned;
+ DWORD dwGranularity;
+ SYSTEM_INFO si;
+
+ dwGranularity = 4; /* 4 B */
+ dwSizeAligned = ((size - 1)/dwGranularity + 1) * dwGranularity;
+
+ return max(dwSizeAligned, 3*dwGranularity); /* at least 12 B */
+}
+
START_TEST(heap)
{
void *mem;
@@ -43,7 +55,8 @@ START_TEST(heap)
SIZE_T heap_size;
mem = HeapAlloc(GetProcessHeap(), 0, size);
heap_size = HeapSize(GetProcessHeap(), 0, mem);
- ok(size == heap_size, "HeapSize returned %lu instead of %lu\n", heap_size, size);
+ ok(heap_size == size || heap_size == resize_9x(size),
+ "HeapSize returned %lu instead of %lu or %lu\n", heap_size, size, resize_9x(size));
HeapFree(GetProcessHeap(), 0, mem);
}
More information about the wine-patches
mailing list