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
222e406d
Commit
222e406d
authored
Oct 31, 2008
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Create a separate heap for allocating memory views instead of using malloc.
parent
bb980042
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
9 deletions
+31
-9
heap.c
dlls/ntdll/heap.c
+1
-1
virtual.c
dlls/ntdll/virtual.c
+30
-8
No files found.
dlls/ntdll/heap.c
View file @
222e406d
...
...
@@ -1253,7 +1253,7 @@ HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T c
list_add_head
(
&
processHeap
->
entry
,
&
heapPtr
->
entry
);
RtlLeaveCriticalSection
(
&
processHeap
->
critSection
);
}
else
else
if
(
!
addr
)
{
processHeap
=
subheap
->
heap
;
/* assume the first heap we create is the process main heap */
list_init
(
&
processHeap
->
entry
);
...
...
dlls/ntdll/virtual.c
View file @
222e406d
...
...
@@ -141,6 +141,9 @@ static void * const user_space_limit = 0; /* no limit needed on other platfo
#define VIRTUAL_DEBUG_DUMP_VIEW(view) \
do { if (TRACE_ON(virtual)) VIRTUAL_DumpView(view); } while (0)
#define VIRTUAL_HEAP_SIZE (4*1024*1024)
static
HANDLE
virtual_heap
;
static
void
*
preload_reserve_start
;
static
void
*
preload_reserve_end
;
static
int
use_locks
;
...
...
@@ -401,7 +404,7 @@ static void delete_view( struct file_view *view ) /* [in] View */
if
(
!
(
view
->
flags
&
VFLAG_SYSTEM
))
unmap_area
(
view
->
base
,
view
->
size
);
list_remove
(
&
view
->
entry
);
if
(
view
->
mapping
)
NtClose
(
view
->
mapping
);
free
(
view
);
RtlFreeHeap
(
virtual_heap
,
0
,
view
);
}
...
...
@@ -421,7 +424,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz
/* Create the view structure */
if
(
!
(
view
=
malloc
(
sizeof
(
*
view
)
+
(
size
>>
page_shift
)
-
1
)))
return
STATUS_NO_MEMORY
;
if
(
!
(
view
=
RtlAllocateHeap
(
virtual_heap
,
0
,
sizeof
(
*
view
)
+
(
size
>>
page_shift
)
-
1
)))
{
FIXME
(
"out of memory in virtual heap for %p-%p
\n
"
,
base
,
(
char
*
)
base
+
size
);
return
STATUS_NO_MEMORY
;
}
view
->
base
=
base
;
view
->
size
=
size
;
...
...
@@ -1167,11 +1174,16 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
}
static
int
get_address_space_limit
(
void
*
base
,
size_t
size
,
void
*
arg
)
/* callback for wine_mmap_enum_reserved_areas to allocate space for the virtual heap */
static
int
alloc_virtual_heap
(
void
*
base
,
size_t
size
,
void
*
arg
)
{
void
**
limit
=
arg
;
if
((
char
*
)
base
+
size
>
(
char
*
)
*
limit
)
*
limit
=
(
char
*
)
base
+
size
;
return
1
;
void
**
heap_base
=
arg
;
if
(
address_space_limit
)
address_space_limit
=
max
(
(
char
*
)
address_space_limit
,
(
char
*
)
base
+
size
);
if
(
size
<
VIRTUAL_HEAP_SIZE
)
return
0
;
*
heap_base
=
wine_anon_mmap
(
(
char
*
)
base
+
size
-
VIRTUAL_HEAP_SIZE
,
VIRTUAL_HEAP_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_FIXED
);
return
(
*
heap_base
!=
(
void
*
)
-
1
);
}
/***********************************************************************
...
...
@@ -1180,6 +1192,9 @@ static int get_address_space_limit( void *base, size_t size, void *arg )
void
virtual_init
(
void
)
{
const
char
*
preload
;
void
*
heap_base
;
struct
file_view
*
heap_view
;
#ifndef page_mask
page_size
=
getpagesize
();
page_mask
=
page_size
-
1
;
...
...
@@ -1197,8 +1212,15 @@ void virtual_init(void)
preload_reserve_end
=
(
void
*
)
end
;
}
}
if
(
address_space_limit
)
wine_mmap_enum_reserved_areas
(
get_address_space_limit
,
&
address_space_limit
,
1
);
/* try to find space in a reserved area for the virtual heap */
if
(
!
wine_mmap_enum_reserved_areas
(
alloc_virtual_heap
,
&
heap_base
,
1
))
heap_base
=
wine_anon_mmap
(
NULL
,
VIRTUAL_HEAP_SIZE
,
PROT_READ
|
PROT_WRITE
,
0
);
assert
(
heap_base
!=
(
void
*
)
-
1
);
virtual_heap
=
RtlCreateHeap
(
HEAP_NO_SERIALIZE
,
heap_base
,
VIRTUAL_HEAP_SIZE
,
VIRTUAL_HEAP_SIZE
,
NULL
,
NULL
);
create_view
(
&
heap_view
,
heap_base
,
VIRTUAL_HEAP_SIZE
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITE
);
}
...
...
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