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
5b4009e8
Commit
5b4009e8
authored
Apr 07, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Apr 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Cleanup heap pointer alignment tests.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8eb9cbd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
37 deletions
+37
-37
heap.c
dlls/kernel32/tests/heap.c
+37
-37
No files found.
dlls/kernel32/tests/heap.c
View file @
5b4009e8
...
...
@@ -75,46 +75,13 @@ struct heap
UINT
force_flags
;
};
static
SIZE_T
resize_9x
(
SIZE_T
size
)
{
DWORD
dwSizeAligned
=
(
size
+
3
)
&
~
3
;
return
max
(
dwSizeAligned
,
12
);
/* at least 12 bytes */
}
static
void
test_heap
(
void
)
{
LPVOID
mem
;
SIZE_T
size
;
/* Heap*() functions */
mem
=
HeapAlloc
(
GetProcessHeap
(),
0
,
0
);
ok
(
mem
!=
NULL
,
"memory not allocated for size 0
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
for
(
size
=
0
;
size
<=
256
;
size
++
)
{
SIZE_T
heap_size
;
mem
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
heap_size
=
HeapSize
(
GetProcessHeap
(),
0
,
mem
);
ok
(
heap_size
==
size
||
heap_size
==
resize_9x
(
size
),
"HeapSize returned %Iu instead of %Iu or %Iu
\n
"
,
heap_size
,
size
,
resize_9x
(
size
));
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
/* large blocks must be 16-byte aligned */
mem
=
HeapAlloc
(
GetProcessHeap
(),
0
,
512
*
1024
);
ok
(
mem
!=
NULL
,
"failed for size 512K
\n
"
);
ok
(
(
ULONG_PTR
)
mem
%
16
==
0
||
broken
((
ULONG_PTR
)
mem
%
16
)
/* win9x */
,
"512K block not 16-byte aligned
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
static
void
test_HeapCreate
(
void
)
{
SIZE_T
alloc_size
=
0x8000
*
sizeof
(
void
*
),
size
;
SIZE_T
alloc_size
=
0x8000
*
sizeof
(
void
*
),
size
,
i
;
BYTE
*
ptr
,
*
ptr1
,
*
ptrs
[
128
];
HANDLE
heap
,
heap1
;
BYTE
*
ptr
,
*
ptr1
;
UINT_PTR
align
;
BOOL
ret
;
/* check heap alignment */
...
...
@@ -186,6 +153,40 @@ static void test_HeapCreate(void)
ret
=
HeapFree
(
heap
,
0
,
ptr
);
ok
(
ret
,
"HeapFree failed, error %lu
\n
"
,
GetLastError
()
);
/* test pointer alignment */
align
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
ptrs
);
++
i
)
{
ptrs
[
i
]
=
HeapAlloc
(
heap
,
0
,
alloc_size
);
ok
(
!!
ptrs
[
i
],
"HeapAlloc failed, error %lu
\n
"
,
GetLastError
()
);
align
|=
(
UINT_PTR
)
ptrs
[
i
];
}
ok
(
!
(
align
&
(
2
*
sizeof
(
void
*
)
-
1
)),
"got wrong alignment
\n
"
);
ok
(
align
&
(
2
*
sizeof
(
void
*
)),
"got wrong alignment
\n
"
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
ptrs
);
++
i
)
{
ret
=
HeapFree
(
heap
,
0
,
ptrs
[
i
]
);
ok
(
ret
,
"HeapFree failed, error %lu
\n
"
,
GetLastError
()
);
}
align
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
ptrs
);
++
i
)
{
ptrs
[
i
]
=
HeapAlloc
(
heap
,
0
,
4
*
alloc_size
);
ok
(
!!
ptrs
[
i
],
"HeapAlloc failed, error %lu
\n
"
,
GetLastError
()
);
align
|=
(
UINT_PTR
)
ptrs
[
i
];
}
todo_wine_if
(
sizeof
(
void
*
)
==
8
)
ok
(
!
(
align
&
(
8
*
sizeof
(
void
*
)
-
1
)),
"got wrong alignment
\n
"
);
todo_wine_if
(
sizeof
(
void
*
)
==
8
)
ok
(
align
&
(
8
*
sizeof
(
void
*
)),
"got wrong alignment
\n
"
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
ptrs
);
++
i
)
{
ret
=
HeapFree
(
heap
,
0
,
ptrs
[
i
]
);
ok
(
ret
,
"HeapFree failed, error %lu
\n
"
,
GetLastError
()
);
}
/* test HEAP_ZERO_MEMORY */
ptr
=
HeapAlloc
(
heap
,
HEAP_ZERO_MEMORY
,
1
);
...
...
@@ -1680,7 +1681,6 @@ START_TEST(heap)
return
;
}
test_heap
();
test_HeapCreate
();
test_GlobalAlloc
();
test_LocalAlloc
();
...
...
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