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
481ecc2d
Commit
481ecc2d
authored
May 18, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
May 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Cleanup HEAP_ShrinkBlock and rename it to shrink_used_block.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c662992d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
19 deletions
+11
-19
heap.c
dlls/ntdll/heap.c
+11
-19
No files found.
dlls/ntdll/heap.c
View file @
481ecc2d
...
@@ -808,26 +808,18 @@ static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena )
...
@@ -808,26 +808,18 @@ static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena )
}
}
/***********************************************************************
static
void
shrink_used_block
(
SUBHEAP
*
subheap
,
struct
block
*
block
,
SIZE_T
data_size
)
* HEAP_ShrinkBlock
*
* Shrink an in-use block.
*/
static
void
HEAP_ShrinkBlock
(
SUBHEAP
*
subheap
,
ARENA_INUSE
*
pArena
,
SIZE_T
size
)
{
{
SIZE_T
old_data_size
=
pArena
->
size
&
ARENA_SIZE_MASK
;
SIZE_T
old_data_size
=
block_get_size
(
block
)
-
sizeof
(
*
block
)
;
if
(
old_data_size
>=
size
+
HEAP_MIN_SHRINK_SIZE
)
if
(
old_data_size
>=
data_
size
+
HEAP_MIN_SHRINK_SIZE
)
{
{
/* assign size plus previous arena flags */
block
->
size
=
data_size
|
block_get_flags
(
block
);
pArena
->
size
=
size
|
(
pArena
->
size
&
~
ARENA_SIZE_MASK
);
HEAP_CreateFreeBlock
(
subheap
,
next_block
(
subheap
,
block
),
old_data_size
-
data_size
);
HEAP_CreateFreeBlock
(
subheap
,
(
char
*
)(
pArena
+
1
)
+
size
,
old_data_size
-
size
);
}
}
else
else
{
{
/* Turn off PREV_FREE flag in next block */
struct
block
*
next
;
char
*
pNext
=
(
char
*
)(
pArena
+
1
)
+
old_data_size
;
if
((
next
=
next_block
(
subheap
,
block
)))
next
->
size
&=
~
ARENA_FLAG_PREV_FREE
;
if
(
pNext
<
(
char
*
)
subheap
->
base
+
subheap
->
size
)
*
(
DWORD
*
)
pNext
&=
~
ARENA_FLAG_PREV_FREE
;
}
}
}
}
...
@@ -1118,7 +1110,7 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T size,
...
@@ -1118,7 +1110,7 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T size,
* last free arena in !
* last free arena in !
* So just one heap struct, one first free arena which will eventually
* So just one heap struct, one first free arena which will eventually
* get used, and a second free arena that might get assigned all remaining
* get used, and a second free arena that might get assigned all remaining
* free space in
HEAP_ShrinkB
lock() */
* free space in
shrink_used_b
lock() */
total_size
=
size
+
ROUND_SIZE
(
sizeof
(
SUBHEAP
))
+
sizeof
(
ARENA_INUSE
)
+
sizeof
(
ARENA_FREE
);
total_size
=
size
+
ROUND_SIZE
(
sizeof
(
SUBHEAP
))
+
sizeof
(
ARENA_INUSE
)
+
sizeof
(
ARENA_FREE
);
if
(
total_size
<
size
)
return
NULL
;
/* overflow */
if
(
total_size
<
size
)
return
NULL
;
/* overflow */
...
@@ -1587,7 +1579,7 @@ static NTSTATUS heap_allocate( HEAP *heap, ULONG flags, SIZE_T size, void **ret
...
@@ -1587,7 +1579,7 @@ static NTSTATUS heap_allocate( HEAP *heap, ULONG flags, SIZE_T size, void **ret
/* Shrink the block */
/* Shrink the block */
HEAP_ShrinkB
lock
(
subheap
,
pInUse
,
rounded_size
);
shrink_used_b
lock
(
subheap
,
pInUse
,
rounded_size
);
pInUse
->
unused_bytes
=
(
pInUse
->
size
&
ARENA_SIZE_MASK
)
-
size
;
pInUse
->
unused_bytes
=
(
pInUse
->
size
&
ARENA_SIZE_MASK
)
-
size
;
notify_alloc
(
pInUse
+
1
,
size
,
flags
&
HEAP_ZERO_MEMORY
);
notify_alloc
(
pInUse
+
1
,
size
,
flags
&
HEAP_ZERO_MEMORY
);
...
@@ -1695,7 +1687,7 @@ static NTSTATUS heap_reallocate( HEAP *heap, ULONG flags, void *ptr, SIZE_T size
...
@@ -1695,7 +1687,7 @@ static NTSTATUS heap_reallocate( HEAP *heap, ULONG flags, void *ptr, SIZE_T size
pArena
->
size
+=
block_get_size
(
next
);
pArena
->
size
+=
block_get_size
(
next
);
if
(
!
HEAP_Commit
(
subheap
,
pArena
,
rounded_size
))
return
STATUS_NO_MEMORY
;
if
(
!
HEAP_Commit
(
subheap
,
pArena
,
rounded_size
))
return
STATUS_NO_MEMORY
;
notify_realloc
(
pArena
+
1
,
oldActualSize
,
size
);
notify_realloc
(
pArena
+
1
,
oldActualSize
,
size
);
HEAP_ShrinkB
lock
(
subheap
,
pArena
,
rounded_size
);
shrink_used_b
lock
(
subheap
,
pArena
,
rounded_size
);
}
}
else
else
{
{
...
@@ -1711,7 +1703,7 @@ static NTSTATUS heap_reallocate( HEAP *heap, ULONG flags, void *ptr, SIZE_T size
...
@@ -1711,7 +1703,7 @@ static NTSTATUS heap_reallocate( HEAP *heap, ULONG flags, void *ptr, SIZE_T size
else
else
{
{
notify_realloc
(
pArena
+
1
,
oldActualSize
,
size
);
notify_realloc
(
pArena
+
1
,
oldActualSize
,
size
);
HEAP_ShrinkB
lock
(
subheap
,
pArena
,
rounded_size
);
shrink_used_b
lock
(
subheap
,
pArena
,
rounded_size
);
}
}
pArena
->
unused_bytes
=
(
pArena
->
size
&
ARENA_SIZE_MASK
)
-
size
;
pArena
->
unused_bytes
=
(
pArena
->
size
&
ARENA_SIZE_MASK
)
-
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