ntdll: Split view search initialization to find_view_inside_range function.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2019-12-26 22:27:26 +01:00 committed by Alexandre Julliard
parent d840d7852b
commit cec83fede4
1 changed files with 23 additions and 5 deletions

View File

@ -496,17 +496,17 @@ static struct file_view *find_view_range( const void *addr, size_t size )
return NULL;
}
/***********************************************************************
* find_reserved_free_area
* find_view_inside_range
*
* Find a free area between views inside the specified range.
* Find first (resp. last, if top_down) view inside a range.
* The csVirtual section must be held by caller.
* The range must be inside the preloader reserved range.
*/
static void *find_reserved_free_area( void *base, void *end, size_t size, size_t mask, int top_down )
static struct wine_rb_entry *find_view_inside_range( void **base_ptr, void **end_ptr, int top_down )
{
struct wine_rb_entry *first = NULL, *ptr = views_tree.root;
void *start;
void *base = *base_ptr, *end = *end_ptr;
/* find the first (resp. last) view inside the range */
while (ptr)
@ -529,6 +529,24 @@ static void *find_reserved_free_area( void *base, void *end, size_t size, size_t
}
}
*base_ptr = base;
*end_ptr = end;
return first;
}
/***********************************************************************
* find_reserved_free_area
*
* Find a free area between views inside the specified range.
* The csVirtual section must be held by caller.
* The range must be inside the preloader reserved range.
*/
static void *find_reserved_free_area( void *base, void *end, size_t size, size_t mask, int top_down )
{
struct wine_rb_entry *first = find_view_inside_range( &base, &end, top_down );
void *start;
if (top_down)
{
start = ROUND_ADDR( (char *)end - size, mask );