There is no need for a private heap in comctl32, memory allocations

should go to the standard process heap (reported by Ge van Geldorp).
This commit is contained in:
Alexandre Julliard 2004-01-26 20:23:08 +00:00
parent c91d9f0c90
commit 4e47ccb490
2 changed files with 25 additions and 74 deletions

View File

@ -57,10 +57,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(commctrl); WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
extern HANDLE COMCTL32_hHeap; /* handle to the private heap */
struct _DSA struct _DSA
{ {
INT nItemCount; INT nItemCount;
@ -370,15 +366,7 @@ DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags,
LPVOID WINAPI Alloc (DWORD dwSize) LPVOID WINAPI Alloc (DWORD dwSize)
{ {
LPVOID lpPtr; return LocalAlloc( LMEM_ZEROINIT, dwSize );
TRACE("(0x%lx)\n", dwSize);
lpPtr = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
TRACE("-- ret=%p\n", lpPtr);
return lpPtr;
} }
@ -403,18 +391,10 @@ LPVOID WINAPI Alloc (DWORD dwSize)
LPVOID WINAPI ReAlloc (LPVOID lpSrc, DWORD dwSize) LPVOID WINAPI ReAlloc (LPVOID lpSrc, DWORD dwSize)
{ {
LPVOID lpDest;
TRACE("(%p 0x%08lx)\n", lpSrc, dwSize);
if (lpSrc) if (lpSrc)
lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize); return LocalReAlloc( lpSrc, dwSize, LMEM_ZEROINIT );
else else
lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize); return LocalAlloc( LMEM_ZEROINIT, dwSize);
TRACE("-- ret=%p\n", lpDest);
return lpDest;
} }
@ -433,9 +413,7 @@ LPVOID WINAPI ReAlloc (LPVOID lpSrc, DWORD dwSize)
BOOL WINAPI Free (LPVOID lpMem) BOOL WINAPI Free (LPVOID lpMem)
{ {
TRACE("(%p)\n", lpMem); return !LocalFree( lpMem );
return HeapFree (COMCTL32_hHeap, 0, lpMem);
} }
@ -455,9 +433,7 @@ BOOL WINAPI Free (LPVOID lpMem)
DWORD WINAPI GetSize (LPVOID lpMem) DWORD WINAPI GetSize (LPVOID lpMem)
{ {
TRACE("(%p)\n", lpMem); return LocalSize( lpMem );
return HeapSize (COMCTL32_hHeap, 0, lpMem);
} }
@ -1655,38 +1631,6 @@ DSA_DeleteAllItems (const HDSA hdsa)
* pointers. * 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 * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
* *
@ -2252,10 +2196,9 @@ DPA_CreateEx (INT nGrow, HANDLE hHeap)
if (hdpa) { if (hdpa) {
hdpa->nGrow = min(8, nGrow); hdpa->nGrow = min(8, nGrow);
hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap; hdpa->hHeap = hHeap ? hHeap : GetProcessHeap();
hdpa->nMaxCount = hdpa->nGrow * 2; hdpa->nMaxCount = hdpa->nGrow * 2;
hdpa->ptrs = hdpa->ptrs = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
(LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
hdpa->nMaxCount * sizeof(LPVOID)); 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 * Notification functions
*/ */

View File

@ -115,7 +115,6 @@ extern void UPDOWN_Register(void);
extern void UPDOWN_Unregister(void); extern void UPDOWN_Unregister(void);
HANDLE COMCTL32_hHeap = NULL;
LPSTR COMCTL32_aSubclass = NULL; LPSTR COMCTL32_aSubclass = NULL;
HMODULE COMCTL32_hModule = 0; HMODULE COMCTL32_hModule = 0;
LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); 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; 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') */ /* add global subclassing atom (used by 'tooltip' and 'updown') */
COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo"); COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo");
TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass); 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)); GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass));
TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass); TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass);
COMCTL32_aSubclass = NULL; COMCTL32_aSubclass = NULL;
/* destroy private heap */
HeapDestroy (COMCTL32_hHeap);
TRACE("Heap destroyed: %p\n", COMCTL32_hHeap);
COMCTL32_hHeap = NULL;
break; break;
} }