Commit 887836cc authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/combo: Use the global memory allocation helpers.

parent e265c493
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "commctrl.h" #include "commctrl.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "comctl32.h" #include "comctl32.h"
...@@ -124,9 +125,9 @@ static BOOL COMBO_Init(void) ...@@ -124,9 +125,9 @@ static BOOL COMBO_Init(void)
*/ */
static LRESULT COMBO_NCCreate(HWND hwnd, LONG style) static LRESULT COMBO_NCCreate(HWND hwnd, LONG style)
{ {
LPHEADCOMBO lphc; HEADCOMBO *lphc;
if (COMBO_Init() && (lphc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEADCOMBO))) ) if (COMBO_Init() && (lphc = heap_alloc_zero(sizeof(*lphc))))
{ {
lphc->self = hwnd; lphc->self = hwnd;
SetWindowLongPtrW( hwnd, 0, (LONG_PTR)lphc ); SetWindowLongPtrW( hwnd, 0, (LONG_PTR)lphc );
...@@ -157,20 +158,20 @@ static LRESULT COMBO_NCCreate(HWND hwnd, LONG style) ...@@ -157,20 +158,20 @@ static LRESULT COMBO_NCCreate(HWND hwnd, LONG style)
/*********************************************************************** /***********************************************************************
* COMBO_NCDestroy * COMBO_NCDestroy
*/ */
static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc ) static LRESULT COMBO_NCDestroy( HEADCOMBO *lphc )
{ {
if (lphc)
{
TRACE("[%p]: freeing storage\n", lphc->self);
if( lphc ) if ( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox )
{ DestroyWindow( lphc->hWndLBox );
TRACE("[%p]: freeing storage\n", lphc->self);
if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox ) SetWindowLongPtrW( lphc->self, 0, 0 );
DestroyWindow( lphc->hWndLBox ); heap_free( lphc );
}
SetWindowLongPtrW( lphc->self, 0, 0 ); return 0;
HeapFree( GetProcessHeap(), 0, lphc );
}
return 0;
} }
/*********************************************************************** /***********************************************************************
...@@ -670,7 +671,7 @@ static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint) ...@@ -670,7 +671,7 @@ static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint)
size = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, id, 0); size = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, id, 0);
if (size == LB_ERR) if (size == LB_ERR)
FIXME("LB_ERR probably not handled yet\n"); FIXME("LB_ERR probably not handled yet\n");
if( (pText = HeapAlloc( GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR))) ) if ((pText = heap_alloc((size + 1) * sizeof(WCHAR))))
{ {
/* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */ /* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */
size=SendMessageW(lphc->hWndLBox, LB_GETTEXT, id, (LPARAM)pText); size=SendMessageW(lphc->hWndLBox, LB_GETTEXT, id, (LPARAM)pText);
...@@ -768,7 +769,8 @@ static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint) ...@@ -768,7 +769,8 @@ static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint)
if( !hdc_paint ) if( !hdc_paint )
ReleaseDC( lphc->self, hdc ); ReleaseDC( lphc->self, hdc );
} }
HeapFree( GetProcessHeap(), 0, pText );
heap_free(pText);
} }
/*********************************************************************** /***********************************************************************
...@@ -891,8 +893,8 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) ...@@ -891,8 +893,8 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect )
idx = LB_ERR; idx = LB_ERR;
length = SendMessageW( lphc->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ); length = SendMessageW( lphc->hWndEdit, WM_GETTEXTLENGTH, 0, 0 );
if( length > 0 ) if (length > 0)
pText = HeapAlloc( GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR)); pText = heap_alloc((length + 1) * sizeof(WCHAR));
TRACE("\t edit text length %i\n", length ); TRACE("\t edit text length %i\n", length );
...@@ -900,7 +902,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) ...@@ -900,7 +902,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect )
{ {
GetWindowTextW( lphc->hWndEdit, pText, length + 1); GetWindowTextW( lphc->hWndEdit, pText, length + 1);
idx = SendMessageW(lphc->hWndLBox, LB_FINDSTRING, -1, (LPARAM)pText); idx = SendMessageW(lphc->hWndLBox, LB_FINDSTRING, -1, (LPARAM)pText);
HeapFree( GetProcessHeap(), 0, pText ); heap_free( pText );
} }
SendMessageW(lphc->hWndLBox, LB_SETCURSEL, bSelect ? idx : -1, 0); SendMessageW(lphc->hWndLBox, LB_SETCURSEL, bSelect ? idx : -1, 0);
...@@ -930,10 +932,8 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index ) ...@@ -930,10 +932,8 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
length = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, index, 0); length = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, index, 0);
if( length != LB_ERR) if( length != LB_ERR)
{ {
if( (pText = HeapAlloc( GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR))) ) if ((pText = heap_alloc((length + 1) * sizeof(WCHAR))))
{
SendMessageW(lphc->hWndLBox, LB_GETTEXT, index, (LPARAM)pText); SendMessageW(lphc->hWndLBox, LB_GETTEXT, index, (LPARAM)pText);
}
} }
} }
...@@ -947,7 +947,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index ) ...@@ -947,7 +947,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
if( lphc->wState & CBF_FOCUSED ) if( lphc->wState & CBF_FOCUSED )
SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1); SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
HeapFree( GetProcessHeap(), 0, pText ); heap_free( pText );
} }
/*********************************************************************** /***********************************************************************
...@@ -1367,7 +1367,7 @@ static LRESULT COMBO_GetText( HEADCOMBO *lphc, INT count, LPWSTR buf ) ...@@ -1367,7 +1367,7 @@ static LRESULT COMBO_GetText( HEADCOMBO *lphc, INT count, LPWSTR buf )
/* 'length' is without the terminating character */ /* 'length' is without the terminating character */
if (length >= count) if (length >= count)
{ {
LPWSTR lpBuffer = HeapAlloc(GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR)); WCHAR *lpBuffer = heap_alloc((length + 1) * sizeof(WCHAR));
if (!lpBuffer) goto error; if (!lpBuffer) goto error;
length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)lpBuffer); length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)lpBuffer);
...@@ -1377,7 +1377,7 @@ static LRESULT COMBO_GetText( HEADCOMBO *lphc, INT count, LPWSTR buf ) ...@@ -1377,7 +1377,7 @@ static LRESULT COMBO_GetText( HEADCOMBO *lphc, INT count, LPWSTR buf )
lstrcpynW( buf, lpBuffer, count ); lstrcpynW( buf, lpBuffer, count );
length = count; length = count;
} }
HeapFree( GetProcessHeap(), 0, lpBuffer ); heap_free( lpBuffer );
} }
else length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)buf); else length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)buf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment