Rémi Bernon : ntdll: Use block helpers in subheap_notify_free_all.
Alexandre Julliard
julliard at winehq.org
Thu May 19 16:15:12 CDT 2022
Module: wine
Branch: master
Commit: 9325bfada79b96fb1bd9de23499b33d5e681079d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9325bfada79b96fb1bd9de23499b33d5e681079d
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Wed May 4 20:33:32 2022 +0200
ntdll: Use block helpers in subheap_notify_free_all.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/heap.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index e4a307bd23a..d0f547faee7 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -383,29 +383,18 @@ static inline void notify_realloc( void const *ptr, SIZE_T size_old, SIZE_T size
#endif
}
-static void subheap_notify_free_all(SUBHEAP const *subheap)
+static void notify_free_all( SUBHEAP *subheap )
{
#ifdef VALGRIND_FREELIKE_BLOCK
- char const *ptr = (char const *)subheap->base + subheap->headerSize;
+ struct block *block;
if (!RUNNING_ON_VALGRIND) return;
if (!check_subheap( subheap )) return;
- while (ptr < (char const *)subheap->base + subheap->size)
+ for (block = first_block( subheap ); block; block = next_block( subheap, block ))
{
- if (*(const DWORD *)ptr & ARENA_FLAG_FREE)
- {
- ARENA_FREE const *pArena = (ARENA_FREE const *)ptr;
- if (pArena->magic!=ARENA_FREE_MAGIC) ERR("bad free_magic @%p\n", pArena);
- ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
- }
- else
- {
- ARENA_INUSE const *pArena = (ARENA_INUSE const *)ptr;
- if (pArena->magic == ARENA_INUSE_MAGIC) notify_free(pArena + 1);
- else if (pArena->magic != ARENA_PENDING_MAGIC) ERR("bad inuse_magic @%p\n", pArena);
- ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
- }
+ if (block_get_flags( block ) & ARENA_FLAG_FREE) continue;
+ if (block_get_type( block ) == ARENA_INUSE_MAGIC) notify_free( block + 1 );
}
#endif
}
@@ -1531,13 +1520,13 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap )
LIST_FOR_EACH_ENTRY_SAFE( subheap, next, &heapPtr->subheap_list, SUBHEAP, entry )
{
if (subheap == &heapPtr->subheap) continue; /* do this one last */
- subheap_notify_free_all(subheap);
+ notify_free_all( subheap );
list_remove( &subheap->entry );
size = 0;
addr = subheap->base;
NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE );
}
- subheap_notify_free_all(&heapPtr->subheap);
+ notify_free_all( &heapPtr->subheap );
RtlFreeHeap( GetProcessHeap(), 0, heapPtr->pending_free );
size = 0;
addr = heapPtr->subheap.base;
More information about the wine-cvs
mailing list