Workaround a msvcrt.realloc bug under Win9x by using Win32 APIs instead
Dmitry Timoshkov
dmitry at baikal.ru
Sat Mar 27 06:57:04 CST 2004
Hello,
realloc in msvcrt.dll has a very nasty bug under Win95 and Win98,
which causes msg.c test fail in the case it's linked dynamically.
I didn't test it under ME, but it's better to avoid using CRT
memory management at all.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
Workaround a msvcrt.realloc bug under Win9x by using Win32 APIs instead.
Take into account that HeapRealloc may move the allocated memory block.
--- cvs/hq/wine/dlls/user/tests/msg.c Sat Mar 27 03:39:34 2004
+++ wine/dlls/user/tests/msg.c Sat Mar 27 12:45:16 2004
@@ -21,9 +21,7 @@
*/
#include <assert.h>
-#include <stdlib.h>
#include <stdarg.h>
-#include <stdio.h>
#include "windef.h"
#include "winbase.h"
@@ -363,12 +361,12 @@ static void add_message(const struct mes
if (!sequence)
{
sequence_size = 10;
- sequence = malloc ( sequence_size * sizeof (struct message) );
+ sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
}
if (sequence_cnt == sequence_size)
{
sequence_size *= 2;
- sequence = realloc ( sequence, sequence_size * sizeof (struct message) );
+ sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
}
assert(sequence);
@@ -382,7 +380,7 @@ static void add_message(const struct mes
static void flush_sequence()
{
- free(sequence);
+ HeapFree(GetProcessHeap(), 0, sequence);
sequence = 0;
sequence_cnt = sequence_size = 0;
}
@@ -390,10 +388,12 @@ static void flush_sequence()
static void ok_sequence(const struct message *expected, const char *context)
{
static const struct message end_of_sequence = { 0, 0, 0, 0 };
- const struct message *actual = sequence;
+ const struct message *actual;
add_message(&end_of_sequence);
+ actual = sequence;
+
while (expected->message && actual->message)
{
trace("expected %04x - actual %04x\n", expected->message, actual->message);
@@ -416,7 +416,7 @@ static void ok_sequence(const struct mes
"%s: the msg 0x%04x was expected in %s\n",
context, expected->message, (expected->flags & parent) ? "parent" : "child");
ok ((expected->flags & hook) == (actual->flags & hook),
- "%s: the msg 0x%04x should have been hooked\n",
+ "%s: the msg 0x%04x should have been sent by a hook\n",
context, expected->message);
expected++;
actual++;
More information about the wine-patches
mailing list