winedbg: Don't dereference possibly NULL thread pointer.
[wine/zf.git] / dlls / explorerframe / tests / msg.h
blob857278e4ef29d27966b95c82e1a54210f1f723f8
1 /* Message Sequence Testing Code
3 * Copyright (C) 2007 James Hawkins
4 * Copyright (C) 2007 Lei Zhang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <assert.h>
22 #include <windows.h>
23 #include "wine/heap.h"
24 #include "wine/test.h"
26 /* undocumented SWP flags - from SDK 3.1 */
27 #define SWP_NOCLIENTSIZE 0x0800
28 #define SWP_NOCLIENTMOVE 0x1000
30 typedef enum
32 sent = 0x1,
33 posted = 0x2,
34 parent = 0x4,
35 wparam = 0x8,
36 lparam = 0x10,
37 defwinproc = 0x20,
38 beginpaint = 0x40,
39 optional = 0x80,
40 hook = 0x100,
41 winevent_hook =0x200,
42 id = 0x400
43 } msg_flags_t;
45 struct message
47 UINT message; /* the WM_* code */
48 msg_flags_t flags; /* message props */
49 WPARAM wParam; /* expected value of wParam */
50 LPARAM lParam; /* expected value of lParam */
51 UINT id; /* extra message data: id of the window,
52 notify code etc. */
55 struct msg_sequence
57 int count;
58 int size;
59 struct message *sequence;
62 static void add_message(struct msg_sequence **seq, int sequence_index,
63 const struct message *msg)
65 struct msg_sequence *msg_seq = seq[sequence_index];
67 if (!msg_seq->sequence)
69 msg_seq->size = 10;
70 msg_seq->sequence = heap_alloc(msg_seq->size * sizeof (struct message));
73 if (msg_seq->count == msg_seq->size)
75 msg_seq->size *= 2;
76 msg_seq->sequence = heap_realloc(msg_seq->sequence, msg_seq->size * sizeof (struct message));
79 assert(msg_seq->sequence);
81 msg_seq->sequence[msg_seq->count].message = msg->message;
82 msg_seq->sequence[msg_seq->count].flags = msg->flags;
83 msg_seq->sequence[msg_seq->count].wParam = msg->wParam;
84 msg_seq->sequence[msg_seq->count].lParam = msg->lParam;
85 msg_seq->sequence[msg_seq->count].id = msg->id;
87 msg_seq->count++;
90 static void flush_sequence(struct msg_sequence **seg, int sequence_index)
92 struct msg_sequence *msg_seq = seg[sequence_index];
93 heap_free(msg_seq->sequence);
94 msg_seq->sequence = NULL;
95 msg_seq->count = msg_seq->size = 0;
98 static void flush_sequences(struct msg_sequence **seq, int n)
100 int i;
102 for (i = 0; i < n; i++)
103 flush_sequence(seq, i);
106 /* ok_sequence is stripped out as it is not currently used. */
108 static void init_msg_sequences(struct msg_sequence **seq, int n)
110 int i;
112 for (i = 0; i < n; i++)
113 seq[i] = heap_alloc_zero(sizeof(struct msg_sequence));