Commit c7d9f75e authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Workaround a msvcrt.realloc bug under Win9x by using Win32 APIs instead.

Take into account that HeapRealloc may move the allocated memory block.
parent 02dd8c36
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
*/ */
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
...@@ -363,12 +361,12 @@ static void add_message(const struct message *msg) ...@@ -363,12 +361,12 @@ static void add_message(const struct message *msg)
if (!sequence) if (!sequence)
{ {
sequence_size = 10; sequence_size = 10;
sequence = malloc ( sequence_size * sizeof (struct message) ); sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
} }
if (sequence_cnt == sequence_size) if (sequence_cnt == sequence_size)
{ {
sequence_size *= 2; sequence_size *= 2;
sequence = realloc ( sequence, sequence_size * sizeof (struct message) ); sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
} }
assert(sequence); assert(sequence);
...@@ -382,7 +380,7 @@ static void add_message(const struct message *msg) ...@@ -382,7 +380,7 @@ static void add_message(const struct message *msg)
static void flush_sequence() static void flush_sequence()
{ {
free(sequence); HeapFree(GetProcessHeap(), 0, sequence);
sequence = 0; sequence = 0;
sequence_cnt = sequence_size = 0; sequence_cnt = sequence_size = 0;
} }
...@@ -390,10 +388,12 @@ static void flush_sequence() ...@@ -390,10 +388,12 @@ static void flush_sequence()
static void ok_sequence(const struct message *expected, const char *context) static void ok_sequence(const struct message *expected, const char *context)
{ {
static const struct message end_of_sequence = { 0, 0, 0, 0 }; 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); add_message(&end_of_sequence);
actual = sequence;
while (expected->message && actual->message) while (expected->message && actual->message)
{ {
trace("expected %04x - actual %04x\n", 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) ...@@ -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", "%s: the msg 0x%04x was expected in %s\n",
context, expected->message, (expected->flags & parent) ? "parent" : "child"); context, expected->message, (expected->flags & parent) ? "parent" : "child");
ok ((expected->flags & hook) == (actual->flags & hook), 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); context, expected->message);
expected++; expected++;
actual++; actual++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment