From c7d9f75eeb3000b7142d8e30a24d11ee75d4996c Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Sat, 27 Mar 2004 20:41:43 +0000 Subject: [PATCH] Workaround a msvcrt.realloc bug under Win9x by using Win32 APIs instead. Take into account that HeapRealloc may move the allocated memory block. --- dlls/user/tests/msg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dlls/user/tests/msg.c b/dlls/user/tests/msg.c index d53aab17ca..57a410b446 100644 --- a/dlls/user/tests/msg.c +++ b/dlls/user/tests/msg.c @@ -21,9 +21,7 @@ */ #include -#include #include -#include #include "windef.h" #include "winbase.h" @@ -363,12 +361,12 @@ static void add_message(const struct message *msg) 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 message *msg) 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 message *expected, const char *context) "%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++;