From 4e47ccb4909e3c9bb52f46a0aa9e49ebe6d87dff Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 26 Jan 2004 20:23:08 +0000 Subject: [PATCH] There is no need for a private heap in comctl32, memory allocations should go to the standard process heap (reported by Ge van Geldorp). --- dlls/comctl32/comctl32undoc.c | 89 ++++++++++------------------------- dlls/comctl32/commctrl.c | 10 ---- 2 files changed, 25 insertions(+), 74 deletions(-) diff --git a/dlls/comctl32/comctl32undoc.c b/dlls/comctl32/comctl32undoc.c index 5c59e5c496f..6a4186eb880 100644 --- a/dlls/comctl32/comctl32undoc.c +++ b/dlls/comctl32/comctl32undoc.c @@ -57,10 +57,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(commctrl); - -extern HANDLE COMCTL32_hHeap; /* handle to the private heap */ - - struct _DSA { INT nItemCount; @@ -370,15 +366,7 @@ DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, LPVOID WINAPI Alloc (DWORD dwSize) { - LPVOID lpPtr; - - TRACE("(0x%lx)\n", dwSize); - - lpPtr = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize); - - TRACE("-- ret=%p\n", lpPtr); - - return lpPtr; + return LocalAlloc( LMEM_ZEROINIT, dwSize ); } @@ -403,18 +391,10 @@ LPVOID WINAPI Alloc (DWORD dwSize) LPVOID WINAPI ReAlloc (LPVOID lpSrc, DWORD dwSize) { - LPVOID lpDest; - - TRACE("(%p 0x%08lx)\n", lpSrc, dwSize); - if (lpSrc) - lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize); + return LocalReAlloc( lpSrc, dwSize, LMEM_ZEROINIT ); else - lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize); - - TRACE("-- ret=%p\n", lpDest); - - return lpDest; + return LocalAlloc( LMEM_ZEROINIT, dwSize); } @@ -433,9 +413,7 @@ LPVOID WINAPI ReAlloc (LPVOID lpSrc, DWORD dwSize) BOOL WINAPI Free (LPVOID lpMem) { - TRACE("(%p)\n", lpMem); - - return HeapFree (COMCTL32_hHeap, 0, lpMem); + return !LocalFree( lpMem ); } @@ -455,9 +433,7 @@ BOOL WINAPI Free (LPVOID lpMem) DWORD WINAPI GetSize (LPVOID lpMem) { - TRACE("(%p)\n", lpMem); - - return HeapSize (COMCTL32_hHeap, 0, lpMem); + return LocalSize( lpMem ); } @@ -1655,38 +1631,6 @@ DSA_DeleteAllItems (const HDSA hdsa) * pointers. */ -/************************************************************************** - * DPA_Create [COMCTL32.328] Creates a dynamic pointer array - * - * PARAMS - * nGrow [I] number of items by which the array grows when it is filled - * - * RETURNS - * Success: handle (pointer) to the pointer array. - * Failure: NULL - */ - -HDPA WINAPI -DPA_Create (INT nGrow) -{ - HDPA hdpa; - - TRACE("(%d)\n", nGrow); - - hdpa = Alloc (sizeof(*hdpa)); - if (hdpa) { - hdpa->nGrow = max(8, nGrow); - hdpa->hHeap = COMCTL32_hHeap; - hdpa->nMaxCount = hdpa->nGrow * 2; - hdpa->ptrs = Alloc (hdpa->nMaxCount * sizeof(LPVOID)); - } - - TRACE("-- %p\n", hdpa); - - return hdpa; -} - - /************************************************************************** * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array * @@ -2252,10 +2196,9 @@ DPA_CreateEx (INT nGrow, HANDLE hHeap) if (hdpa) { hdpa->nGrow = min(8, nGrow); - hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap; + hdpa->hHeap = hHeap ? hHeap : GetProcessHeap(); hdpa->nMaxCount = hdpa->nGrow * 2; - hdpa->ptrs = - (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, + hdpa->ptrs = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->nMaxCount * sizeof(LPVOID)); } @@ -2265,6 +2208,24 @@ DPA_CreateEx (INT nGrow, HANDLE hHeap) } +/************************************************************************** + * DPA_Create [COMCTL32.328] Creates a dynamic pointer array + * + * PARAMS + * nGrow [I] number of items by which the array grows when it is filled + * + * RETURNS + * Success: handle (pointer) to the pointer array. + * Failure: NULL + */ + +HDPA WINAPI +DPA_Create (INT nGrow) +{ + return DPA_CreateEx( nGrow, 0 ); +} + + /************************************************************************** * Notification functions */ diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index bb1464c8593..cf33c32d54e 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -115,7 +115,6 @@ extern void UPDOWN_Register(void); extern void UPDOWN_Unregister(void); -HANDLE COMCTL32_hHeap = NULL; LPSTR COMCTL32_aSubclass = NULL; HMODULE COMCTL32_hModule = 0; LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); @@ -154,10 +153,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) COMCTL32_hModule = (HMODULE)hinstDLL; - /* create private heap */ - COMCTL32_hHeap = HeapCreate (0, 0x10000, 0); - TRACE("Heap created: %p\n", COMCTL32_hHeap); - /* add global subclassing atom (used by 'tooltip' and 'updown') */ COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo"); TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass); @@ -218,11 +213,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass)); TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass); COMCTL32_aSubclass = NULL; - - /* destroy private heap */ - HeapDestroy (COMCTL32_hHeap); - TRACE("Heap destroyed: %p\n", COMCTL32_hHeap); - COMCTL32_hHeap = NULL; break; }