winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
December 2022
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
539 discussions
Start a n
N
ew thread
Rémi Bernon : ntdll: Merge prev and next free heap blocks in heap_free_block.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: 911e1f378c13852dc500cc6ce60327790192dc31 URL:
https://gitlab.winehq.org/wine/wine/-/commit/911e1f378c13852dc500cc6ce60327…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Mon Nov 14 21:06:34 2022 +0100 ntdll: Merge prev and next free heap blocks in heap_free_block. As create_free_block is only called in other places where it is not possible to have a free block either before or after. --- dlls/ntdll/heap.c | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 88744d79f80..b8996415da0 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -725,16 +725,6 @@ static void create_free_block( struct heap *heap, ULONG flags, SUBHEAP *subheap, if (end > commit_end) end = commit_end; if (end > (char *)(entry + 1)) mark_block_free( entry + 1, end - (char *)(entry + 1), flags ); - if ((next = next_block( subheap, block )) && (block_get_flags( next ) & BLOCK_FLAG_FREE)) - { - /* merge with the next block if it is free */ - struct entry *next_entry = (struct entry *)next; - list_remove( &next_entry->entry ); - block_size += block_get_size( next ); - block_set_size( block, block_size ); - mark_block_free( next_entry, sizeof(*next_entry), flags ); - } - if ((next = next_block( subheap, block ))) { /* set the next block PREV_FREE flag and back pointer */ @@ -772,40 +762,44 @@ static struct block *heap_delay_free( struct heap *heap, ULONG flags, struct blo static NTSTATUS heap_free_block( struct heap *heap, ULONG flags, struct block *block ) { + SUBHEAP *subheap = block_get_subheap( heap, block ); + SIZE_T block_size = block_get_size( block ); struct entry *entry; - SIZE_T block_size; - SUBHEAP *subheap; + struct block *next; + + if ((next = next_block( subheap, block )) && (block_get_flags( next ) & BLOCK_FLAG_FREE)) + { + /* merge with next block if it is free */ + entry = (struct entry *)next; + block_size += block_get_size( &entry->block ); + list_remove( &entry->entry ); + next = next_block( subheap, next ); + } - block_size = block_get_size( block ); if (block_get_flags( block ) & BLOCK_FLAG_PREV_FREE) { /* merge with previous block if it is free */ - block = *((struct block **)block - 1); - block_size += block_get_size( block ); - entry = (struct entry *)block; + entry = *((struct entry **)block - 1); + block_size += block_get_size( &entry->block ); list_remove( &entry->entry ); + block = &entry->block; } - else entry = (struct entry *)block; - subheap = block_get_subheap( heap, block ); - create_free_block( heap, flags, subheap, block, block_size ); - if (next_block( subheap, block )) return STATUS_SUCCESS; /* not the last block */ - - if (block == first_block( subheap ) && subheap != &heap->subheap) + if (block == first_block( subheap ) && !next && subheap != &heap->subheap) { /* free the subheap if it's empty and not the main one */ void *addr = subheap_base( subheap ); SIZE_T size = 0; - list_remove( &entry->entry ); list_remove( &subheap->entry ); NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); + return STATUS_SUCCESS; } - else - { - /* keep room for a full committed block as hysteresis */ - subheap_decommit( heap, subheap, (char *)(entry + 1) + REGION_ALIGN ); - } + + create_free_block( heap, flags, subheap, block, block_size ); + + /* keep room for a full committed block as hysteresis */ + if (!next) subheap_decommit( heap, subheap, (char *)((struct entry *)block + 1) + REGION_ALIGN ); return STATUS_SUCCESS; }
1
0
0
0
Rémi Bernon : ntdll: Split heap blocks before creating or resizing used block.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: bece622b8e804112146591a8059d2e4e1543dd41 URL:
https://gitlab.winehq.org/wine/wine/-/commit/bece622b8e804112146591a8059d2e…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Nov 25 18:11:57 2022 +0100 ntdll: Split heap blocks before creating or resizing used block. --- dlls/ntdll/heap.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 02e4be09cdd..88744d79f80 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -811,22 +811,19 @@ static NTSTATUS heap_free_block( struct heap *heap, ULONG flags, struct block *b } -static inline void shrink_used_block( struct heap *heap, ULONG flags, struct block *block, - SIZE_T old_block_size, SIZE_T block_size, SIZE_T size ) +static struct block *split_block( struct heap *heap, ULONG flags, struct block *block, + SIZE_T old_block_size, SIZE_T block_size ) { SUBHEAP *subheap = block_get_subheap( heap, block ); if (old_block_size >= block_size + HEAP_MIN_BLOCK_SIZE) { block_set_size( block, block_size ); - block->tail_size = block_size - sizeof(*block) - size; - create_free_block( heap, flags, subheap, next_block( subheap, block ), old_block_size - block_size ); - } - else - { - block_set_size( block, old_block_size ); - block->tail_size = old_block_size - sizeof(*block) - size; + return next_block( subheap, block ); } + + block_set_size( block, old_block_size ); + return NULL; } @@ -1510,9 +1507,12 @@ static NTSTATUS heap_allocate_block( struct heap *heap, ULONG flags, SIZE_T bloc old_block_size = block_get_size( block ); subheap = block_get_subheap( heap, block ); + if ((next = split_block( heap, flags, block, old_block_size, block_size ))) + create_free_block( heap, flags, subheap, next, old_block_size - block_size ); + block_set_type( block, BLOCK_TYPE_USED ); block_set_flags( block, ~0, BLOCK_USER_FLAGS( flags ) ); - shrink_used_block( heap, flags, block, old_block_size, block_size, size ); + block->tail_size = block_get_size( block ) - sizeof(*block) - size; initialize_block( block, 0, size, flags ); mark_block_tail( block, flags ); @@ -1642,9 +1642,12 @@ static NTSTATUS heap_resize_block( struct heap *heap, ULONG flags, struct block old_block_size += block_get_size( next ); } + if ((next = split_block( heap, flags, block, old_block_size, block_size ))) + create_free_block( heap, flags, subheap, next, old_block_size - block_size ); + valgrind_notify_resize( block + 1, *old_size, size ); block_set_flags( block, BLOCK_FLAG_USER_MASK & ~BLOCK_FLAG_USER_INFO, BLOCK_USER_FLAGS( flags ) ); - shrink_used_block( heap, flags, block, old_block_size, block_size, size ); + block->tail_size = block_get_size( block ) - sizeof(*block) - size; initialize_block( block, *old_size, size, flags ); mark_block_tail( block, flags );
1
0
0
0
Rémi Bernon : ntdll: Clear BLOCK_FLAG_PREV_FREE flag out of shrink_used_block.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: a540b4b2461431392da5dee7ac4995640be9e455 URL:
https://gitlab.winehq.org/wine/wine/-/commit/a540b4b2461431392da5dee7ac4995…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Nov 25 17:52:54 2022 +0100 ntdll: Clear BLOCK_FLAG_PREV_FREE flag out of shrink_used_block. --- dlls/ntdll/heap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index c4371ec78fd..02e4be09cdd 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -824,10 +824,8 @@ static inline void shrink_used_block( struct heap *heap, ULONG flags, struct blo } else { - struct block *next; block_set_size( block, old_block_size ); block->tail_size = old_block_size - sizeof(*block) - size; - if ((next = next_block( subheap, block ))) block_set_flags( next, BLOCK_FLAG_PREV_FREE, 0 ); } } @@ -1501,14 +1499,16 @@ static SIZE_T heap_get_block_size( const struct heap *heap, ULONG flags, SIZE_T static NTSTATUS heap_allocate_block( struct heap *heap, ULONG flags, SIZE_T block_size, SIZE_T size, void **ret ) { + struct block *block, *next; SIZE_T old_block_size; - struct block *block; + SUBHEAP *subheap; /* Locate a suitable free block */ if (!(block = find_free_block( heap, flags, block_size ))) return STATUS_NO_MEMORY; /* read the free block size, changing block type or flags may alter it */ old_block_size = block_get_size( block ); + subheap = block_get_subheap( heap, block ); block_set_type( block, BLOCK_TYPE_USED ); block_set_flags( block, ~0, BLOCK_USER_FLAGS( flags ) ); @@ -1516,6 +1516,8 @@ static NTSTATUS heap_allocate_block( struct heap *heap, ULONG flags, SIZE_T bloc initialize_block( block, 0, size, flags ); mark_block_tail( block, flags ); + if ((next = next_block( subheap, block ))) block_set_flags( next, BLOCK_FLAG_PREV_FREE, 0 ); + *ret = block + 1; return STATUS_SUCCESS; } @@ -1643,10 +1645,11 @@ static NTSTATUS heap_resize_block( struct heap *heap, ULONG flags, struct block valgrind_notify_resize( block + 1, *old_size, size ); block_set_flags( block, BLOCK_FLAG_USER_MASK & ~BLOCK_FLAG_USER_INFO, BLOCK_USER_FLAGS( flags ) ); shrink_used_block( heap, flags, block, old_block_size, block_size, size ); - initialize_block( block, *old_size, size, flags ); mark_block_tail( block, flags ); + if ((next = next_block( subheap, block ))) block_set_flags( next, BLOCK_FLAG_PREV_FREE, 0 ); + heap_unlock( heap, flags ); *ret = block + 1;
1
0
0
0
Rémi Bernon : ntdll: Move heap allocation and initialization into RtlCreateHeap.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: 99388f74c7b81a0051ca098df1e20cf510e16fff URL:
https://gitlab.winehq.org/wine/wine/-/commit/99388f74c7b81a0051ca098df1e20c…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Thu Dec 1 18:56:00 2022 +0100 ntdll: Move heap allocation and initialization into RtlCreateHeap. And rename HEAP_CreateSubHeap to create_subheap. --- dlls/ntdll/heap.c | 153 ++++++++++++++++++++++++------------------------------ 1 file changed, 68 insertions(+), 85 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 74a922dde24..c4371ec78fd 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -944,88 +944,22 @@ static BOOL validate_large_block( const struct heap *heap, const struct block *b return !err; } -/*********************************************************************** - * HEAP_CreateSubHeap - */ -static SUBHEAP *HEAP_CreateSubHeap( struct heap **heap_ptr, LPVOID address, DWORD flags, - SIZE_T commitSize, SIZE_T totalSize ) + +static SUBHEAP *create_subheap( struct heap *heap, DWORD flags, SIZE_T total_size, SIZE_T commit_size ) { - struct heap *heap = *heap_ptr; - struct entry *pEntry; SIZE_T block_size; SUBHEAP *subheap; - unsigned int i; - - if (!address) - { - if (!commitSize) commitSize = REGION_ALIGN; - totalSize = min( max( totalSize, commitSize ), 0xffff0000 ); /* don't allow a heap larger than 4GB */ - commitSize = min( totalSize, ROUND_SIZE( commitSize, REGION_ALIGN - 1 ) ); - if (!(address = allocate_region( heap, flags, &totalSize, &commitSize ))) return NULL; - } - - if (heap) - { - /* If this is a secondary subheap, insert it into list */ - - subheap = address; - subheap_set_bounds( subheap, (char *)address + commitSize, (char *)address + totalSize ); - list_add_head( &heap->subheap_list, &subheap->entry ); - } - else - { - /* If this is a primary subheap, initialize main heap */ - - heap = address; - heap->ffeeffee = 0xffeeffee; - heap->auto_flags = (flags & HEAP_GROWABLE); - heap->flags = (flags & ~HEAP_SHARED); - heap->magic = HEAP_MAGIC; - heap->grow_size = max( HEAP_DEF_SIZE, totalSize ); - heap->min_size = commitSize; - list_init( &heap->subheap_list ); - list_init( &heap->large_list ); - subheap = &heap->subheap; - subheap_set_bounds( subheap, (char *)address + commitSize, (char *)address + totalSize ); - list_add_head( &heap->subheap_list, &subheap->entry ); + commit_size = ROUND_SIZE( max( commit_size, REGION_ALIGN ), REGION_ALIGN - 1 ); + total_size = min( max( commit_size, total_size ), 0xffff0000 ); /* don't allow a heap larger than 4GB */ - /* Build the free lists */ - - list_init( &heap->free_lists[0].entry ); - for (i = 0, pEntry = heap->free_lists; i < HEAP_NB_FREE_LISTS; i++, pEntry++) - { - block_set_flags( &pEntry->block, ~0, BLOCK_FLAG_FREE_LINK ); - block_set_size( &pEntry->block, 0 ); - block_set_type( &pEntry->block, BLOCK_TYPE_FREE ); - block_set_base( &pEntry->block, heap ); - if (i) list_add_after( &pEntry[-1].entry, &pEntry->entry ); - } + if (!(subheap = allocate_region( heap, flags, &total_size, &commit_size ))) return NULL; - /* Initialize critical section */ - - if (!process_heap) /* do it by hand to avoid memory allocations */ - { - heap->cs.DebugInfo = &process_heap_cs_debug; - heap->cs.LockCount = -1; - heap->cs.RecursionCount = 0; - heap->cs.OwningThread = 0; - heap->cs.LockSemaphore = 0; - heap->cs.SpinCount = 0; - process_heap_cs_debug.CriticalSection = &heap->cs; - } - else - { - RtlInitializeCriticalSection( &heap->cs ); - heap->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": heap.cs"); - } - } - - block_size = subheap_size( subheap ) - subheap_overhead( subheap ); - block_size &= ~(BLOCK_ALIGN - 1); + subheap_set_bounds( subheap, (char *)subheap + commit_size, (char *)subheap + total_size ); + block_size = (SIZE_T)ROUND_ADDR( subheap_size( subheap ) - subheap_overhead( subheap ), BLOCK_ALIGN - 1 ); create_free_block( heap, flags, subheap, first_block( subheap ), block_size ); + list_add_head( &heap->subheap_list, &subheap->entry ); - *heap_ptr = heap; return subheap; } @@ -1057,8 +991,7 @@ static struct block *find_free_block( struct heap *heap, ULONG flags, SIZE_T blo total_size = sizeof(SUBHEAP) + block_size + sizeof(struct entry); if (total_size < block_size) return NULL; /* overflow */ - if ((subheap = HEAP_CreateSubHeap( &heap, NULL, flags, total_size, - max( heap->grow_size, total_size ) ))) + if ((subheap = create_subheap( heap, flags, max( heap->grow_size, total_size ), total_size ))) { if (heap->grow_size <= HEAP_MAX_FREE_BLOCK_SIZE / 2) heap->grow_size *= 2; } @@ -1066,8 +999,7 @@ static struct block *find_free_block( struct heap *heap, ULONG flags, SIZE_T blo { if (heap->grow_size <= total_size || heap->grow_size <= 4 * 1024 * 1024) return NULL; heap->grow_size /= 2; - subheap = HEAP_CreateSubHeap( &heap, NULL, flags, total_size, - max( heap->grow_size, total_size ) ); + subheap = create_subheap( heap, flags, max( heap->grow_size, total_size ), total_size ); } TRACE( "created new sub-heap %p of %#Ix bytes for heap %p\n", subheap, subheap_size( subheap ), heap ); @@ -1388,20 +1320,71 @@ static void heap_set_debug_flags( HANDLE handle ) * Success: A HANDLE to the newly created heap. * Failure: a NULL HANDLE. */ -HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T commitSize, - PVOID unknown, PRTL_HEAP_DEFINITION definition ) +HANDLE WINAPI RtlCreateHeap( ULONG flags, void *addr, SIZE_T total_size, SIZE_T commit_size, + void *unknown, RTL_HEAP_DEFINITION *definition ) { - struct heap *heap = NULL; + struct entry *entry; + struct heap *heap; + SIZE_T block_size; SUBHEAP *subheap; + unsigned int i; - /* Allocate the heap block */ + TRACE( "flags %#lx, addr %p, total_size %#Ix, commit_size %#Ix, unknown %p, definition %p\n", + flags, addr, total_size, commit_size, unknown, definition ); flags &= ~(HEAP_TAIL_CHECKING_ENABLED|HEAP_FREE_CHECKING_ENABLED); if (process_heap) flags |= HEAP_PRIVATE; - if (!process_heap || !totalSize || (flags & HEAP_SHARED)) flags |= HEAP_GROWABLE; - if (!totalSize) totalSize = HEAP_DEF_SIZE; + if (!process_heap || !total_size || (flags & HEAP_SHARED)) flags |= HEAP_GROWABLE; + if (!total_size) total_size = HEAP_DEF_SIZE; + + if (!(heap = addr)) + { + if (!commit_size) commit_size = REGION_ALIGN; + total_size = min( max( total_size, commit_size ), 0xffff0000 ); /* don't allow a heap larger than 4GB */ + commit_size = min( total_size, ROUND_SIZE( commit_size, REGION_ALIGN - 1 ) ); + if (!(heap = allocate_region( NULL, flags, &total_size, &commit_size ))) return 0; + } + + heap->ffeeffee = 0xffeeffee; + heap->auto_flags = (flags & HEAP_GROWABLE); + heap->flags = (flags & ~HEAP_SHARED); + heap->magic = HEAP_MAGIC; + heap->grow_size = max( HEAP_DEF_SIZE, total_size ); + heap->min_size = commit_size; + list_init( &heap->subheap_list ); + list_init( &heap->large_list ); - if (!(subheap = HEAP_CreateSubHeap( &heap, addr, flags, commitSize, totalSize ))) return 0; + list_init( &heap->free_lists[0].entry ); + for (i = 0, entry = heap->free_lists; i < HEAP_NB_FREE_LISTS; i++, entry++) + { + block_set_flags( &entry->block, ~0, BLOCK_FLAG_FREE_LINK ); + block_set_size( &entry->block, 0 ); + block_set_type( &entry->block, BLOCK_TYPE_FREE ); + block_set_base( &entry->block, heap ); + if (i) list_add_after( &entry[-1].entry, &entry->entry ); + } + + if (!process_heap) /* do it by hand to avoid memory allocations */ + { + heap->cs.DebugInfo = &process_heap_cs_debug; + heap->cs.LockCount = -1; + heap->cs.RecursionCount = 0; + heap->cs.OwningThread = 0; + heap->cs.LockSemaphore = 0; + heap->cs.SpinCount = 0; + process_heap_cs_debug.CriticalSection = &heap->cs; + } + else + { + RtlInitializeCriticalSection( &heap->cs ); + heap->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": heap.cs"); + } + + subheap = &heap->subheap; + subheap_set_bounds( subheap, (char *)heap + commit_size, (char *)heap + total_size ); + block_size = (SIZE_T)ROUND_ADDR( subheap_size( subheap ) - subheap_overhead( subheap ), BLOCK_ALIGN - 1 ); + create_free_block( heap, flags, subheap, first_block( subheap ), block_size ); + list_add_head( &heap->subheap_list, &subheap->entry ); heap_set_debug_flags( heap );
1
0
0
0
Rémi Bernon : ntdll: Split heap region memory allocation to allocate_region helper.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: dd037455ca91124aa724b1c9bb44521377cca8f2 URL:
https://gitlab.winehq.org/wine/wine/-/commit/dd037455ca91124aa724b1c9bb4452…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Thu Dec 1 11:00:05 2022 +0100 ntdll: Split heap region memory allocation to allocate_region helper. --- dlls/ntdll/heap.c | 69 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 1de9fe6a4b6..74a922dde24 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -832,27 +832,48 @@ static inline void shrink_used_block( struct heap *heap, ULONG flags, struct blo } +static void *allocate_region( struct heap *heap, ULONG flags, SIZE_T *region_size, SIZE_T *commit_size ) +{ + void *addr = NULL; + NTSTATUS status; + + if (heap && !(flags & HEAP_GROWABLE)) + { + WARN( "Heap %p isn't growable, cannot allocate %#Ix bytes\n", heap, *region_size ); + return NULL; + } + + /* allocate the memory block */ + if ((status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, region_size, MEM_RESERVE, + get_protection_type( flags ) ))) + { + WARN( "Could not allocate %#Ix bytes, status %#lx\n", *region_size, status ); + return NULL; + } + if ((status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, commit_size, MEM_COMMIT, + get_protection_type( flags ) ))) + { + WARN( "Could not commit %#Ix bytes, status %#lx\n", *commit_size, status ); + return NULL; + } + + return addr; +} + + 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 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 STATUS_NO_MEMORY; - } + if (!(arena = allocate_region( heap, flags, &total_size, &total_size ))) return STATUS_NO_MEMORY; - arena = address; block = &arena->block; arena->data_size = size; - arena->block_size = (char *)address + total_size - (char *)block; + arena->block_size = (char *)arena + total_size - (char *)block; block_set_type( block, BLOCK_TYPE_LARGE ); block_set_base( block, arena ); @@ -938,23 +959,9 @@ static SUBHEAP *HEAP_CreateSubHeap( struct heap **heap_ptr, LPVOID address, DWOR if (!address) { if (!commitSize) commitSize = REGION_ALIGN; - totalSize = min( totalSize, 0xffff0000 ); /* don't allow a heap larger than 4GB */ - if (totalSize < commitSize) totalSize = commitSize; - commitSize = min( totalSize, (SIZE_T)ROUND_ADDR( commitSize + REGION_ALIGN - 1, REGION_ALIGN - 1 ) ); - - /* allocate the memory block */ - if (NtAllocateVirtualMemory( NtCurrentProcess(), &address, 0, &totalSize, MEM_RESERVE, - get_protection_type( flags ) )) - { - WARN( "Could not allocate %#Ix bytes\n", totalSize ); - return NULL; - } - if (NtAllocateVirtualMemory( NtCurrentProcess(), &address, 0, &commitSize, MEM_COMMIT, - get_protection_type( flags ) )) - { - WARN( "Could not commit %#Ix bytes for sub-heap %p\n", commitSize, address ); - return NULL; - } + totalSize = min( max( totalSize, commitSize ), 0xffff0000 ); /* don't allow a heap larger than 4GB */ + commitSize = min( totalSize, ROUND_SIZE( commitSize, REGION_ALIGN - 1 ) ); + if (!(address = allocate_region( heap, flags, &totalSize, &commitSize ))) return NULL; } if (heap) @@ -1046,14 +1053,6 @@ static struct block *find_free_block( struct heap *heap, ULONG flags, SIZE_T blo } } - /* If no block was found, attempt to grow the heap */ - - if (!(flags & HEAP_GROWABLE)) - { - WARN( "Not enough space in heap %p for %#Ix bytes\n", heap, block_size ); - return NULL; - } - /* make sure we can fit the block and a free entry at the end */ total_size = sizeof(SUBHEAP) + block_size + sizeof(struct entry); if (total_size < block_size) return NULL; /* overflow */
1
0
0
0
Rémi Bernon : inetcomm: Allocate PROPVARIANT memory with CoTaskMemAlloc.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: 3c2ab50b09aa0dbbc657043c26a6f373a24d5ebd URL:
https://gitlab.winehq.org/wine/wine/-/commit/3c2ab50b09aa0dbbc657043c26a6f3…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Dec 2 01:30:13 2022 +0100 inetcomm: Allocate PROPVARIANT memory with CoTaskMemAlloc. --- dlls/inetcomm/mimeole.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index ceacf5ded42..232e09aa075 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -1089,7 +1089,8 @@ static HRESULT WINAPI MimeBody_GetProp( { PropVariantClear(pValue); pValue->vt = VT_LPSTR; - pValue->pszVal = strdup(This->content_pri_type); + pValue->pszVal = CoTaskMemAlloc(strlen(This->content_pri_type) + 1); + strcpy(pValue->pszVal, This->content_pri_type); return S_OK; }
1
0
0
0
Rémi Bernon : user32: Avoid freeing invalid pointers in WIN_CreateWindowEx.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: 984969be5600244b443c59287457a5b78e811b77 URL:
https://gitlab.winehq.org/wine/wine/-/commit/984969be5600244b443c59287457a5…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Dec 2 01:25:50 2022 +0100 user32: Avoid freeing invalid pointers in WIN_CreateWindowEx. --- dlls/user32/win.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index a6f43c188c4..d8869b2b9db 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -278,7 +278,7 @@ static BOOL is_default_coord( int x ) */ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, BOOL unicode ) { - UNICODE_STRING class, window_name; + UNICODE_STRING class, window_name = {0}; HWND hwnd, top_child = 0; MDICREATESTRUCTW mdi_cs; WNDCLASSEXW info; @@ -401,7 +401,7 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, cs->x, cs->y, cs->cx, cs->cy, cs->hwndParent, menu, module, cs->lpCreateParams, 0, NULL, 0, !unicode ); if (!hwnd && menu && menu != cs->hMenu) NtUserDestroyMenu( menu ); - if (!unicode) RtlFreeUnicodeString( &window_name ); + if (!unicode && window_name.Buffer != name_buf) RtlFreeUnicodeString( &window_name ); return hwnd; }
1
0
0
0
Rémi Bernon : kernel32/tests: Avoid releasing invalid path pointer.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: 54b37a37027828864882e89ab4655c27f05f72cb URL:
https://gitlab.winehq.org/wine/wine/-/commit/54b37a37027828864882e89ab4655c…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Dec 2 01:32:03 2022 +0100 kernel32/tests: Avoid releasing invalid path pointer. --- dlls/kernel32/tests/path.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 3c57e81f4c6..2c657e26b24 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -2653,7 +2653,6 @@ static void test_LdrGetDllPath(void) ret = pLdrGetDllPath( buffer, LOAD_WITH_ALTERED_SEARCH_PATH | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, &path, &unknown_ptr ); ok( ret == STATUS_INVALID_PARAMETER, "got %lx expected %lx\n", ret, STATUS_INVALID_PARAMETER ); ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr ); - pRtlReleasePath( path ); lstrcpyW( buffer, dlldir ); p = buffer + lstrlenW(buffer);
1
0
0
0
Rémi Bernon : advapi32/tests: Only free GetSecurityInfo pointer on success.
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: 0204e6e33a05f80fe4d19b71a9c6d8fba9acf3fb URL:
https://gitlab.winehq.org/wine/wine/-/commit/0204e6e33a05f80fe4d19b71a9c6d8…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Dec 2 01:25:29 2022 +0100 advapi32/tests: Only free GetSecurityInfo pointer on success. --- dlls/advapi32/tests/security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c index 51bf60d0f36..8b4a868ee11 100644 --- a/dlls/advapi32/tests/security.c +++ b/dlls/advapi32/tests/security.c @@ -8083,7 +8083,7 @@ static void test_pseudo_handle_security(void) "key %p: got error %u\n", keys[i], ret); else ok(!ret, "key %p: got error %u\n", keys[i], ret); - LocalFree(sd_ptr); + if (!ret) LocalFree(sd_ptr); ret = GetSecurityInfo(keys[i], SE_KERNEL_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL, &sd_ptr);
1
0
0
0
Zebediah Figura : d3d9/tests: Do not test the alpha channel in test_multisample_get_front_buffer_data().
by Alexandre Julliard
02 Dec '22
02 Dec '22
Module: wine Branch: master Commit: ab0488d712f260111976eafd36253f88e178ace7 URL:
https://gitlab.winehq.org/wine/wine/-/commit/ab0488d712f260111976eafd36253f…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Fri May 27 17:06:32 2022 -0500 d3d9/tests: Do not test the alpha channel in test_multisample_get_front_buffer_data(). This avoids test failures on radeonsi. --- dlls/d3d9/tests/visual.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index f8375d238e4..d1bcaf39c14 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -17788,7 +17788,7 @@ static void test_multisample_get_front_buffer_data(void) hr = IDirect3DDevice9_GetFrontBufferData(device, 0, readback); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); color = getPixelColorFromSurface(readback, 320, 240); - ok(color == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color); + ok((color & 0x00ffffff) == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color); IDirect3DSurface9_Release(readback); hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1, @@ -17800,7 +17800,7 @@ static void test_multisample_get_front_buffer_data(void) hr = IDirect3DDevice9_GetFrontBufferData(device, 0, readback); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); color = getPixelColorFromSurface(readback, 320, 240); - ok(color == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color); + ok((color & 0x00ffffff) == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color); IDirect3DSurface9_Release(readback); IDirect3DTexture9_Release(texture);
1
0
0
0
← Newer
1
...
45
46
47
48
49
50
51
...
54
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Results per page:
10
25
50
100
200