83{
92
95
98
99
101 ok(
mem !=
NULL,
"memory not allocated for size 0\n");
103
105 ok(
mem ==
NULL,
"memory allocated by HeapReAlloc\n");
106
108 {
113 "HeapSize returned %lu instead of %lu or %lu\n", heap_size,
size,
resize_9x(
size));
115 }
116
117
119 ok(
mem !=
NULL,
"memory not allocated for size 0\n");
121 ok(msecond ==
NULL,
"HeapReAlloc(~0 - 7) should have failed\n");
123 ok(msecond ==
NULL,
"HeapReAlloc(~0) should have failed\n");
126 ok(
mem ==
NULL,
"memory allocated for size ~0\n");
129 ok(msecond !=
NULL,
"HeapReAlloc(0) should have succeeded\n");
132 "HeapSize should have returned 0 instead of %lu\n",
size);
134
135
137 ok(
mem !=
NULL,
"failed for size 512K\n" );
139 "512K block not 16-byte aligned\n" );
141
142
144 ok(gbl !=
NULL,
"global memory not allocated for size 0\n");
145
147 ok(gbl !=
NULL,
"Can't realloc global memory\n");
149 ok(
size >= 10 &&
size <= 16,
"Memory not resized to size 10, instead size=%ld\n",
size);
150
152 ok(gbl !=
NULL,
"GlobalReAlloc should not fail on size 0\n");
153
155 ok(
size == 0,
"Memory not resized to size 0, instead size=%ld\n",
size);
158 ok(
size == 0,
"Memory should have been freed, size=%ld\n",
size);
159
161 ok(gbl ==
NULL,
"global realloc allocated memory\n");
162
163
165
171 ok(
flags == 1,
"returned 0x%04x with %d (expected '0x0001')\n",
173
176 ok( msecond ==
mem,
"returned %p with %d (expected '%p')\n",
180 ok(
flags == 2,
"returned 0x%04x with %d (expected '0x0002')\n",
183
189 ok(
flags ,
"returned 0x%04x with %d (expected '!= 0')\n",
191
194
196 "returned %d with %d (expected '0' with: ERROR_SUCCESS or "
200 ok( !
flags ,
"returned 0x%04x with %d (expected '0')\n",
202
203
206
209 "returned %d with %d (expected '0' with: ERROR_NOT_LOCKED or "
211
213
217 "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
222 "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
228 "returned %p with 0x%08x (expected %p with ERROR_NOACCESS)\n",
230
234 "returned 0x%04x with 0x%08x (expected GMEM_INVALID_HANDLE with "
239 "returned %ld with 0x%08x (expected '0' with ERROR_INVALID_HANDLE)\n",
241
245 "returned %p with 0x%08x (expected NULL with ERROR_INVALID_HANDLE)\n",
247
248
249
250
251
255 "returned %d with %d (expected ERROR_INVALID_HANDLE)\n",
257
259
260
263
264
265 if (sizeof(void *) != 8)
266 {
273 "Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
274 }
275
276
282 "got %p with %x (expected %p or NULL) @%ld\n", hsecond,
GetLastError(), gbl,
size);
284 }
285
286
292 "got %p with %x (expected non-NULL) @%ld\n", hsecond,
GetLastError(),
size);
294 ok(
mem == hsecond,
"got %p (expected %p) @%ld\n",
mem, hsecond,
size);
296 }
297
299
303 "Expected 1 or 0, got %d\n",
res);
304
308 "Expected 1 or 0, got %d\n",
res);
309
311
313
318 "Expected 1 or 0, got %d\n",
res);
320
322
323
324 if (sizeof(void *) != 8)
325 {
331 "Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
332 }
333
339
340
341
343 ok(gbl !=
NULL,
"local memory not allocated for size 0\n");
344
346 ok(gbl !=
NULL,
"Can't realloc local memory\n");
348 ok(
size >= 10 &&
size <= 16,
"Memory not resized to size 10, instead size=%ld\n",
size);
349
351 ok(gbl !=
NULL,
"LocalReAlloc should not fail on size 0\n");
352
354 ok(
size == 0,
"Memory not resized to size 0, instead size=%ld\n",
size);
357 ok(
size == 0,
"Memory should have been freed, size=%ld\n",
size);
358
360 ok(gbl ==
NULL,
"local realloc allocated memory\n");
361
362
369 ok(
flags == 1,
"returned 0x%04x with %d (expected '0x0001')\n",
371
374 ok( msecond ==
mem,
"returned %p with %d (expected '%p')\n",
378 ok(
flags == 2,
"returned 0x%04x with %d (expected '0x0002')\n",
381
387 ok(
flags ,
"returned 0x%04x with %d (expected '!= 0')\n",
389
392
394 "returned %d with %d (expected '0' with: ERROR_SUCCESS or "
398 ok( !
flags ,
"returned 0x%04x with %d (expected '0')\n",
400
401
404
407 "returned %d with %d (expected '0' with: ERROR_NOT_LOCKED or "
409
411
415 "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
420 "returned 0x%04x with 0x%08x (expected LMEM_INVALID_HANDLE with "
425 "returned %ld with 0x%08x (expected '0' with ERROR_INVALID_HANDLE)\n",
427
431 "returned %p with 0x%08x (expected NULL with ERROR_INVALID_HANDLE)\n",
433
434
438 "returned %d with %d (expected '0' with ERROR_INVALID_HANDLE)\n",
440
441
447 "got %p with %x (expected %p or NULL) @%ld\n", hsecond,
GetLastError(), gbl,
size);
449 }
450
451
457 "got %p with %x (expected non-NULL) @%ld\n", hsecond,
GetLastError(),
size);
459 ok(
mem == hsecond,
"got %p (expected %p) @%ld\n",
mem, hsecond,
size);
461 }
462
463
467 ok(
res == 0,
"Expected 0, got %d\n",
res);
471
476 "wrong size %lu\n",
size );
478
479
481 ok(gbl !=
NULL,
"returned NULL\n");
484
487 "returned %p with 0x%x/%d (expected 'NULL' with: ERROR_DISCARDED or "
489
491
492
494 ok(gbl !=
NULL,
"returned NULL\n");
497 ok(gbl !=
mem,
"unexpectedly equal.\n");
498
502 ok(size2 == 0x123,
"got %lu\n", size2);
503
505
506
508 ok(gbl !=
NULL,
"returned NULL\n");
511 ok(gbl ==
mem,
"got %p, %p.\n", gbl,
mem);
512
515
517
520
521}
#define ERROR_NOT_ENOUGH_MEMORY
#define HeapFree(x, y, z)
#define ERROR_INVALID_HANDLE
UINT NTAPI GlobalFlags(HGLOBAL hMem)
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
LPVOID NTAPI LocalLock(HLOCAL hMem)
BOOL NTAPI LocalUnlock(HLOCAL hMem)
SIZE_T NTAPI LocalSize(HLOCAL hMem)
UINT NTAPI LocalFlags(HLOCAL hMem)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
static SIZE_T resize_9x(SIZE_T size)
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
#define GMEM_INVALID_HANDLE
#define LMEM_INVALID_HANDLE