From: Alex Henrie alexhenrie24@gmail.com
The big win here is getting rid of the reimplementation of strdup. --- dlls/user32/combo.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 5ea61c607be..d61e10ae26d 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -26,6 +26,7 @@ #include "user_private.h" #include "controls.h" #include "wine/debug.h" +#include "stdlib.h"
WINE_DEFAULT_DEBUG_CHANNEL(combo);
@@ -112,7 +113,7 @@ static LRESULT COMBO_NCCreate(HWND hwnd, LONG style) { LPHEADCOMBO lphc;
- if (COMBO_Init() && (lphc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEADCOMBO))) ) + if( COMBO_Init() && (lphc = calloc( 1, sizeof(HEADCOMBO) )) ) { lphc->self = hwnd; SetWindowLongPtrW( hwnd, 0, (LONG_PTR)lphc ); @@ -154,7 +155,7 @@ static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc ) NtUserDestroyWindow( lphc->hWndLBox );
SetWindowLongPtrW( lphc->self, 0, 0 ); - HeapFree( GetProcessHeap(), 0, lphc ); + free( lphc ); } return 0; } @@ -641,7 +642,7 @@ static void CBPaintText( size = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, id, 0); if (size == LB_ERR) FIXME("LB_ERR probably not handled yet\n"); - if( (pText = HeapAlloc( GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR))) ) + if( (pText = malloc((size + 1) * sizeof(WCHAR))) ) { /* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */ size=SendMessageW(lphc->hWndLBox, LB_GETTEXT, id, (LPARAM)pText); @@ -736,7 +737,7 @@ static void CBPaintText( if (!hdc_paint) NtUserReleaseDC( lphc->self, hdc ); } - HeapFree( GetProcessHeap(), 0, pText ); + free(pText); }
/*********************************************************************** @@ -830,7 +831,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) length = SendMessageW( lphc->hWndEdit, WM_GETTEXTLENGTH, 0, 0 );
if( length > 0 ) - pText = HeapAlloc( GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR)); + pText = malloc((length + 1) * sizeof(WCHAR));
TRACE("\t edit text length %i\n", length );
@@ -838,7 +839,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) { GetWindowTextW( lphc->hWndEdit, pText, length + 1); idx = SendMessageW(lphc->hWndLBox, LB_FINDSTRING, -1, (LPARAM)pText); - HeapFree( GetProcessHeap(), 0, pText ); + free(pText); }
SendMessageW(lphc->hWndLBox, LB_SETCURSEL, bSelect ? idx : -1, 0); @@ -867,7 +868,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index ) length = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, index, 0); if( length != LB_ERR) { - if( (pText = HeapAlloc( GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR))) ) + if( (pText = malloc((length + 1) * sizeof(WCHAR))) ) { SendMessageW(lphc->hWndLBox, LB_GETTEXT, index, (LPARAM)pText); } @@ -884,7 +885,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index ) if( lphc->wState & CBF_FOCUSED ) SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
- HeapFree( GetProcessHeap(), 0, pText ); + free(pText); }
/*********************************************************************** @@ -1295,7 +1296,7 @@ static LRESULT COMBO_GetTextW( LPHEADCOMBO lphc, INT count, LPWSTR buf ) /* 'length' is without the terminating character */ if (length >= count) { - LPWSTR lpBuffer = HeapAlloc(GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR)); + WCHAR *lpBuffer = malloc((length + 1) * sizeof(WCHAR)); if (!lpBuffer) goto error; length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)lpBuffer);
@@ -1305,7 +1306,7 @@ static LRESULT COMBO_GetTextW( LPHEADCOMBO lphc, INT count, LPWSTR buf ) lstrcpynW( buf, lpBuffer, count ); length = count; } - HeapFree( GetProcessHeap(), 0, lpBuffer ); + free(lpBuffer); } else length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)buf);
@@ -1345,7 +1346,7 @@ static LRESULT COMBO_GetTextA( LPHEADCOMBO lphc, INT count, LPSTR buf ) /* 'length' is without the terminating character */ if (length >= count) { - LPSTR lpBuffer = HeapAlloc(GetProcessHeap(), 0, (length + 1) ); + char *lpBuffer = malloc(length + 1); if (!lpBuffer) goto error; length = SendMessageA(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)lpBuffer);
@@ -1355,7 +1356,7 @@ static LRESULT COMBO_GetTextA( LPHEADCOMBO lphc, INT count, LPSTR buf ) lstrcpynA( buf, lpBuffer, count ); length = count; } - HeapFree( GetProcessHeap(), 0, lpBuffer ); + free(lpBuffer); } else length = SendMessageA(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)buf);
@@ -1678,19 +1679,6 @@ static LRESULT COMBO_GetComboBoxInfo(const HEADCOMBO *lphc, COMBOBOXINFO *pcbi) return TRUE; }
-static char *strdupA(LPCSTR str) -{ - char *ret; - DWORD len; - - if(!str) return NULL; - - len = strlen(str); - ret = HeapAlloc(GetProcessHeap(), 0, len + 1); - memcpy(ret, str, len + 1); - return ret; -} - /*********************************************************************** * ComboWndProc_common */ @@ -1927,18 +1915,18 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar LRESULT ret; if( lphc->dwStyle & CBS_LOWERCASE ) { - string = strdupA((LPSTR)lParam); + string = strdup((char *)lParam); CharLowerA(string); }
else if( lphc->dwStyle & CBS_UPPERCASE ) { - string = strdupA((LPSTR)lParam); + string = strdup((char *)lParam); CharUpperA(string); }
ret = SendMessageA(lphc->hWndLBox, LB_ADDSTRING, 0, string ? (LPARAM)string : lParam); - HeapFree(GetProcessHeap(), 0, string); + free(string); return ret; } case CB_INSERTSTRING: