[PATCH 0/1] MR1349: user32: Use standard C functions for memory allocation in combo.c.
The big win here is getting rid of the reimplementation of strdup. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1349
From: Alex Henrie <alexhenrie24(a)gmail.com> The big win here is getting rid of the reimplementation of strdup. --- dlls/user32/combo.c | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 5ea61c607be..538ff338e9f 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -112,7 +112,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 +154,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 +641,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 +736,7 @@ static void CBPaintText( if (!hdc_paint) NtUserReleaseDC( lphc->self, hdc ); } - HeapFree( GetProcessHeap(), 0, pText ); + free(pText); } /*********************************************************************** @@ -830,7 +830,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 +838,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 +867,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 +884,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 +1295,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 +1305,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 +1345,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 +1355,7 @@ static LRESULT COMBO_GetTextA( LPHEADCOMBO lphc, INT count, LPSTR buf ) lstrcpynA( buf, lpBuffer, count ); length = count; } - HeapFree( GetProcessHeap(), 0, lpBuffer ); + free(pBuffer); } else length = SendMessageA(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)buf); @@ -1678,19 +1678,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 +1914,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: -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1349
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126122 Your paranoid android. === debian11 (build log) === ../wine/dlls/user32/combo.c:1358:18: error: ���pBuffer��� undeclared (first use in this function); did you mean ���lpBuffer���? Task: The win32 Wine build failed === debian11b (build log) === ../wine/dlls/user32/combo.c:1358:18: error: ���pBuffer��� undeclared (first use in this function); did you mean ���lpBuffer���? Task: The wow64 Wine build failed
participants (3)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Marvin