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
e2258ef5
Commit
e2258ef5
authored
Apr 28, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
May 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Split RtlFreeHeap to a separate heap_free helper.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
dadb1fa7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
43 deletions
+30
-43
heap.c
dlls/kernel32/tests/heap.c
+2
-0
heap.c
dlls/ntdll/heap.c
+28
-43
No files found.
dlls/kernel32/tests/heap.c
View file @
e2258ef5
...
...
@@ -229,6 +229,8 @@ static void test_HeapCreate(void)
/* test some border cases */
ret
=
HeapFree
(
NULL
,
0
,
NULL
);
ok
(
ret
,
"HeapFree failed, error %lu
\n
"
,
GetLastError
()
);
ret
=
HeapFree
(
heap
,
0
,
NULL
);
ok
(
ret
,
"HeapFree failed, error %lu
\n
"
,
GetLastError
()
);
#if 0 /* crashes */
...
...
dlls/ntdll/heap.c
View file @
e2258ef5
...
...
@@ -1725,60 +1725,45 @@ void *WINAPI DECLSPEC_HOTPATCH RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_T
}
/***********************************************************************
* RtlFreeHeap (NTDLL.@)
*
* Free a memory block allocated with RtlAllocateHeap().
*
* PARAMS
* heap [I] Heap that block was allocated from
* flags [I] HEAP_ flags from "winnt.h"
* ptr [I] Block to free
*
* RETURNS
* Success: TRUE, if ptr is NULL or was freed successfully.
* Failure: FALSE.
*/
BOOLEAN
WINAPI
DECLSPEC_HOTPATCH
RtlFreeHeap
(
HANDLE
heap
,
ULONG
flags
,
void
*
ptr
)
static
NTSTATUS
heap_free
(
HEAP
*
heap
,
void
*
ptr
)
{
ARENA_INUSE
*
pInUse
;
ARENA_INUSE
*
block
;
SUBHEAP
*
subheap
;
HEAP
*
heapPtr
;
/* Validate the parameters */
/* Inform valgrind we are trying to free memory, so it can throw up an error message */
notify_free
(
ptr
);
if
(
!
ptr
)
return
TRUE
;
/* freeing a NULL ptr isn't an error in Win2k */
block
=
(
ARENA_INUSE
*
)
ptr
-
1
;
if
(
!
validate_block_pointer
(
heap
,
&
subheap
,
block
))
return
STATUS_INVALID_PARAMETER
;
heapPtr
=
HEAP_GetPtr
(
heap
);
if
(
!
heapPtr
)
{
RtlSetLastWin32ErrorAndNtStatusFromNtStatus
(
STATUS_INVALID_HANDLE
);
return
FALSE
;
}
if
(
!
subheap
)
free_large_block
(
heap
,
ptr
);
else
HEAP_MakeInUseBlockFree
(
subheap
,
block
);
heap_lock
(
heapPtr
,
flags
);
return
STATUS_SUCCESS
;
}
/* Inform valgrind we are trying to free memory, so it can throw up an error message */
notify_free
(
ptr
);
/***********************************************************************
* RtlFreeHeap (NTDLL.@)
*/
BOOLEAN
WINAPI
DECLSPEC_HOTPATCH
RtlFreeHeap
(
HANDLE
heap
,
ULONG
flags
,
void
*
ptr
)
{
NTSTATUS
status
;
HEAP
*
heapPtr
;
/* Some sanity checks */
pInUse
=
(
ARENA_INUSE
*
)
ptr
-
1
;
if
(
!
validate_block_pointer
(
heapPtr
,
&
subheap
,
pInUse
))
goto
error
;
if
(
!
ptr
)
return
TRUE
;
if
(
!
subheap
)
free_large_block
(
heapPtr
,
ptr
)
;
if
(
!
(
heapPtr
=
HEAP_GetPtr
(
heap
))
)
status
=
STATUS_INVALID_PARAMETER
;
else
HEAP_MakeInUseBlockFree
(
subheap
,
pInUse
);
heap_unlock
(
heapPtr
,
flags
);
TRACE
(
"(%p,%08x,%p): returning TRUE
\n
"
,
heap
,
flags
,
ptr
);
return
TRUE
;
{
heap_lock
(
heapPtr
,
flags
);
status
=
heap_free
(
heapPtr
,
ptr
);
heap_unlock
(
heapPtr
,
flags
);
}
error:
heap_unlock
(
heapPtr
,
flags
);
RtlSetLastWin32ErrorAndNtStatusFromNtStatus
(
STATUS_INVALID_PARAMETER
);
TRACE
(
"(%p,%08x,%p): returning FALSE
\n
"
,
heap
,
flags
,
ptr
);
return
FALSE
;
TRACE
(
"heap %p, flags %#x, ptr %p, return %u, status %#x.
\n
"
,
heap
,
flags
,
ptr
,
!
status
,
status
);
heap_set_status
(
heapPtr
,
flags
,
status
);
return
!
status
;
}
...
...
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