Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
523d4cc4
Commit
523d4cc4
authored
Nov 14, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Move large block alloc out of heap_allocate.
parent
a7fda2f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
heap.c
dlls/ntdll/heap.c
+15
-18
No files found.
dlls/ntdll/heap.c
View file @
523d4cc4
...
...
@@ -819,23 +819,21 @@ static inline void shrink_used_block( struct heap *heap, ULONG flags, struct blo
}
/***********************************************************************
* allocate_large_block
*/
static
struct
block
*
allocate_large_block
(
struct
heap
*
heap
,
DWORD
flags
,
SIZE_T
size
)
static
NTSTATUS
heap_allocate_large
(
struct
heap
*
heap
,
ULONG
flags
,
SIZE_T
block_size
,
SIZE_T
size
,
void
**
ret
)
{
ARENA_LARGE
*
arena
;
SIZE_T
total_size
=
ROUND_SIZE
(
sizeof
(
*
arena
)
+
size
,
REGION_ALIGN
-
1
);
LPVOID
address
=
NULL
;
struct
block
*
block
;
if
(
!
(
flags
&
HEAP_GROWABLE
))
return
NULL
;
if
(
total_size
<
size
)
return
NULL
;
/* overflow */
if
(
!
(
flags
&
HEAP_GROWABLE
))
return
STATUS_NO_MEMORY
;
if
(
total_size
<
size
)
return
STATUS_NO_MEMORY
;
/* overflow */
if
(
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
address
,
0
,
&
total_size
,
MEM_COMMIT
,
get_protection_type
(
heap
->
flags
)
))
{
WARN
(
"Could not allocate block for %#Ix bytes
\n
"
,
size
);
return
NULL
;
return
STATUS_NO_MEMORY
;
}
arena
=
address
;
...
...
@@ -847,11 +845,16 @@ static struct block *allocate_large_block( struct heap *heap, DWORD flags, SIZE_
block_set_base
(
block
,
arena
);
block_set_flags
(
block
,
~
0
,
BLOCK_FLAG_LARGE
|
BLOCK_USER_FLAGS
(
flags
)
);
block_set_size
(
block
,
0
);
heap_lock
(
heap
,
flags
);
list_add_tail
(
&
heap
->
large_list
,
&
arena
->
entry
);
heap_unlock
(
heap
,
flags
);
valgrind_make_noaccess
(
(
char
*
)
block
+
sizeof
(
*
block
)
+
arena
->
data_size
,
arena
->
block_size
-
sizeof
(
*
block
)
-
arena
->
data_size
);
return
block
;
*
ret
=
block
+
1
;
return
STATUS_SUCCESS
;
}
...
...
@@ -1501,19 +1504,11 @@ static SIZE_T heap_get_block_size( const struct heap *heap, ULONG flags, SIZE_T
return
block_size
;
}
static
NTSTATUS
heap_allocate
(
struct
heap
*
heap
,
ULONG
flags
,
SIZE_T
block_size
,
SIZE_T
size
,
void
**
ret
)
static
NTSTATUS
heap_allocate
_block
(
struct
heap
*
heap
,
ULONG
flags
,
SIZE_T
block_size
,
SIZE_T
size
,
void
**
ret
)
{
SIZE_T
old_block_size
;
struct
block
*
block
;
if
(
block_size
>=
HEAP_MIN_LARGE_BLOCK_SIZE
)
{
if
(
!
(
block
=
allocate_large_block
(
heap
,
flags
,
size
)))
return
STATUS_NO_MEMORY
;
*
ret
=
block
+
1
;
return
STATUS_SUCCESS
;
}
/* Locate a suitable free block */
if
(
!
(
block
=
find_free_block
(
heap
,
flags
,
block_size
)))
return
STATUS_NO_MEMORY
;
...
...
@@ -1545,10 +1540,12 @@ void *WINAPI DECLSPEC_HOTPATCH RtlAllocateHeap( HANDLE handle, ULONG flags, SIZE
status
=
STATUS_INVALID_HANDLE
;
else
if
((
block_size
=
heap_get_block_size
(
heap
,
heap_flags
,
size
))
==
~
0U
)
status
=
STATUS_NO_MEMORY
;
else
if
(
block_size
>=
HEAP_MIN_LARGE_BLOCK_SIZE
)
status
=
heap_allocate_large
(
heap
,
heap_flags
,
block_size
,
size
,
&
ptr
);
else
{
heap_lock
(
heap
,
heap_flags
);
status
=
heap_allocate
(
heap
,
heap_flags
,
block_size
,
size
,
&
ptr
);
status
=
heap_allocate
_block
(
heap
,
heap_flags
,
block_size
,
size
,
&
ptr
);
heap_unlock
(
heap
,
heap_flags
);
}
...
...
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