Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
1451aa58
Commit
1451aa58
authored
11 years ago
by
Akihiro Sagawa
Committed by
Alexandre Julliard
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
kernel32: Add more GlobalReAlloc/LocalReAlloc tests.
parent
842798f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/kernel32/tests/heap.c
+61
-0
61 additions, 0 deletions
dlls/kernel32/tests/heap.c
with
61 additions
and
0 deletions
dlls/kernel32/tests/heap.c
+
61
−
0
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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment