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
3e6d0789
Commit
3e6d0789
authored
Apr 23, 2009
by
Dan Kegel
Committed by
Alexandre Julliard
Apr 27, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add missing RtlReAllocateHeap Valgrind hook, add tests.
parent
52b1de84
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
heap.c
dlls/kernel32/tests/heap.c
+37
-1
heap.c
dlls/ntdll/heap.c
+4
-0
No files found.
dlls/kernel32/tests/heap.c
View file @
3e6d0789
...
...
@@ -34,7 +34,30 @@ static SIZE_T resize_9x(SIZE_T size)
return
max
(
dwSizeAligned
,
12
);
/* at least 12 bytes */
}
START_TEST
(
heap
)
static
void
test_sized_HeapAlloc
(
int
nbytes
)
{
int
success
;
char
*
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
nbytes
);
ok
(
buf
!=
NULL
,
"allocate failed"
);
ok
(
buf
[
0
]
==
0
,
"buffer not zeroed"
);
success
=
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
ok
(
success
,
"free failed"
);
}
static
void
test_sized_HeapReAlloc
(
int
nbytes1
,
int
nbytes2
)
{
int
success
;
char
*
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
nbytes1
);
ok
(
buf
!=
NULL
,
"allocate failed"
);
ok
(
buf
[
0
]
==
0
,
"buffer not zeroed"
);
buf
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
buf
,
nbytes2
);
ok
(
buf
!=
NULL
,
"reallocate failed"
);
ok
(
buf
[
nbytes2
-
1
]
==
0
,
"buffer not zeroed"
);
success
=
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
ok
(
success
,
"free failed"
);
}
static
void
test_heap
(
void
)
{
LPVOID
mem
;
LPVOID
msecond
;
...
...
@@ -338,3 +361,16 @@ START_TEST(heap)
GlobalFree
(
gbl
);
}
START_TEST
(
heap
)
{
test_heap
();
/* Test both short and very long blocks */
test_sized_HeapAlloc
(
1
);
test_sized_HeapAlloc
(
1
<<
20
);
test_sized_HeapReAlloc
(
1
,
100
);
test_sized_HeapReAlloc
(
1
,
(
1
<<
20
));
test_sized_HeapReAlloc
((
1
<<
20
),
(
2
<<
20
));
test_sized_HeapReAlloc
((
1
<<
20
),
1
);
}
dlls/ntdll/heap.c
View file @
3e6d0789
...
...
@@ -1535,6 +1535,8 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size
{
if
(
!
find_large_block
(
heapPtr
,
ptr
))
goto
error
;
if
(
!
(
ret
=
realloc_large_block
(
heapPtr
,
flags
,
ptr
,
size
)))
goto
oom
;
notify_free
(
ptr
);
notify_alloc
(
ret
,
size
,
flags
&
HEAP_ZERO_MEMORY
);
goto
done
;
}
if
((
char
*
)
pArena
<
(
char
*
)
subheap
->
base
+
subheap
->
headerSize
)
goto
error
;
...
...
@@ -1551,7 +1553,9 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size
if
(
rounded_size
>=
HEAP_MIN_LARGE_BLOCK_SIZE
&&
(
flags
&
HEAP_GROWABLE
))
{
if
(
!
(
ret
=
allocate_large_block
(
heapPtr
,
flags
,
size
)))
goto
oom
;
notify_alloc
(
ret
,
size
,
flags
&
HEAP_ZERO_MEMORY
);
memcpy
(
ret
,
pArena
+
1
,
oldActualSize
);
/* FIXME: free old memory here! */
goto
done
;
}
if
((
pNext
<
(
char
*
)
subheap
->
base
+
subheap
->
size
)
&&
...
...
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