Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1451aa58
Commit
1451aa58
authored
Jun 01, 2013
by
Akihiro Sagawa
Committed by
Alexandre Julliard
Jun 03, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add more GlobalReAlloc/LocalReAlloc tests.
parent
842798f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
heap.c
dlls/kernel32/tests/heap.c
+61
-0
No files found.
dlls/kernel32/tests/heap.c
View file @
1451aa58
...
...
@@ -86,6 +86,7 @@ static void test_heap(void)
HGLOBAL
gbl
;
HGLOBAL
hsecond
;
SIZE_T
size
,
size2
;
const
SIZE_T
max_size
=
1024
,
init_size
=
10
;
/* Heap*() functions */
mem
=
HeapAlloc
(
GetProcessHeap
(),
0
,
0
);
...
...
@@ -245,6 +246,36 @@ static void test_heap(void)
"Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
}
/* GMEM_FIXED block expands in place only without flags */
for
(
size
=
1
;
size
<=
max_size
;
size
<<=
1
)
{
gbl
=
GlobalAlloc
(
GMEM_FIXED
,
init_size
);
SetLastError
(
MAGIC_DEAD
);
hsecond
=
GlobalReAlloc
(
gbl
,
size
+
init_size
,
0
);
if
(
hsecond
!=
gbl
)
{
todo_wine
ok
(
hsecond
==
gbl
||
(
hsecond
==
NULL
&&
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
),
"got %p with %x (expected %p or NULL) @%ld
\n
"
,
hsecond
,
GetLastError
(),
gbl
,
size
);
GlobalFree
(
hsecond
);
}
else
{
ok
(
hsecond
==
gbl
||
(
hsecond
==
NULL
&&
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
),
"got %p with %x (expected %p or NULL) @%ld
\n
"
,
hsecond
,
GetLastError
(),
gbl
,
size
);
GlobalFree
(
gbl
);
}
}
/* GMEM_FIXED block can be relocated with GMEM_MOVEABLE */
for
(
size
=
1
;
size
<=
max_size
;
size
<<=
1
)
{
gbl
=
GlobalAlloc
(
GMEM_FIXED
,
init_size
);
SetLastError
(
MAGIC_DEAD
);
hsecond
=
GlobalReAlloc
(
gbl
,
size
+
init_size
,
GMEM_MOVEABLE
);
ok
(
hsecond
!=
NULL
,
"got %p with %x (expected non-NULL) @%ld
\n
"
,
hsecond
,
GetLastError
(),
size
);
mem
=
GlobalLock
(
hsecond
);
ok
(
mem
==
hsecond
,
"got %p (expected %p) @%ld
\n
"
,
mem
,
hsecond
,
size
);
GlobalFree
(
hsecond
);
}
gbl
=
GlobalAlloc
(
GMEM_DDESHARE
,
100
);
res
=
GlobalUnlock
(
gbl
);
...
...
@@ -382,6 +413,36 @@ static void test_heap(void)
"returned %d with %d (expected '0' with ERROR_INVALID_HANDLE)
\n
"
,
res
,
GetLastError
());
/* LMEM_FIXED block expands in place only without flags */
for
(
size
=
1
;
size
<=
max_size
;
size
<<=
1
)
{
gbl
=
LocalAlloc
(
LMEM_FIXED
,
init_size
);
SetLastError
(
MAGIC_DEAD
);
hsecond
=
LocalReAlloc
(
gbl
,
size
+
init_size
,
0
);
if
(
hsecond
!=
gbl
)
{
todo_wine
ok
(
hsecond
==
gbl
||
(
hsecond
==
NULL
&&
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
),
"got %p with %x (expected %p or NULL) @%ld
\n
"
,
hsecond
,
GetLastError
(),
gbl
,
size
);
LocalFree
(
hsecond
);
}
else
{
ok
(
hsecond
==
gbl
||
(
hsecond
==
NULL
&&
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
),
"got %p with %x (expected %p or NULL) @%ld
\n
"
,
hsecond
,
GetLastError
(),
gbl
,
size
);
LocalFree
(
gbl
);
}
}
/* LMEM_FIXED memory can be relocated with LMEM_MOVEABLE */
for
(
size
=
1
;
size
<=
max_size
;
size
<<=
1
)
{
gbl
=
LocalAlloc
(
LMEM_FIXED
,
init_size
);
SetLastError
(
MAGIC_DEAD
);
hsecond
=
LocalReAlloc
(
gbl
,
size
+
init_size
,
LMEM_MOVEABLE
);
ok
(
hsecond
!=
NULL
,
"got %p with %x (expected non-NULL) @%ld
\n
"
,
hsecond
,
GetLastError
(),
size
);
mem
=
LocalLock
(
hsecond
);
ok
(
mem
==
hsecond
,
"got %p (expected %p) @%ld
\n
"
,
mem
,
hsecond
,
size
);
LocalFree
(
hsecond
);
}
/* trying to unlock pointer from LocalAlloc */
gbl
=
LocalAlloc
(
LMEM_FIXED
,
100
);
SetLastError
(
0xdeadbeef
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment