From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/listbox.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index 6724dee1487..d29cfc3968a 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -33,7 +33,6 @@ #include "vssym32.h" #include "wine/exception.h" #include "wine/debug.h" -#include "wine/heap.h"
#include "comctl32.h"
@@ -153,7 +152,7 @@ static BOOL resize_storage(LB_DESCR *descr, UINT items_size) items_size = (items_size + LB_ARRAY_GRANULARITY - 1) & ~(LB_ARRAY_GRANULARITY - 1); if ((descr->style & (LBS_NODATA | LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != LBS_NODATA) { - items = heap_realloc(descr->u.items, items_size * get_sizeof_item(descr)); + items = realloc(descr->u.items, items_size * get_sizeof_item(descr)); if (!items) { SEND_NOTIFICATION(descr, LBN_ERRSPACE); @@ -819,16 +818,15 @@ static BOOL LISTBOX_SetTabStops( LB_DESCR *descr, INT count, LPINT tabs ) return FALSE; }
- HeapFree( GetProcessHeap(), 0, descr->tabs ); + free( descr->tabs ); if (!(descr->nb_tabs = count)) { descr->tabs = NULL; return TRUE; } - if (!(descr->tabs = HeapAlloc( GetProcessHeap(), 0, - descr->nb_tabs * sizeof(INT) ))) + if (!(descr->tabs = malloc( descr->nb_tabs * sizeof(*descr->tabs) ))) return FALSE; - memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) ); + memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(*descr->tabs) );
/* convert into "dialog units"*/ for (i = 0; i < descr->nb_tabs; i++) @@ -1695,7 +1693,7 @@ static LRESULT LISTBOX_InsertString( LB_DESCR *descr, INT index, LPCWSTR str ) if (HAS_STRINGS(descr)) { if (!str) str = L""; - if (!(new_str = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR) ))) + if (!(new_str = malloc( (lstrlenW(str) + 1) * sizeof(WCHAR) ))) { SEND_NOTIFICATION( descr, LBN_ERRSPACE ); return LB_ERRSPACE; @@ -1706,7 +1704,7 @@ static LRESULT LISTBOX_InsertString( LB_DESCR *descr, INT index, LPCWSTR str ) if (index == -1) index = descr->nb_items; if ((ret = LISTBOX_InsertItem( descr, index, new_str, (ULONG_PTR)str )) != 0) { - HeapFree( GetProcessHeap(), 0, new_str ); + free( new_str ); return ret; }
@@ -1740,7 +1738,7 @@ static void LISTBOX_DeleteItem( LB_DESCR *descr, INT index ) dis.itemData = get_item_data(descr, index); SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis ); } - HeapFree( GetProcessHeap(), 0, get_item_string(descr, index) ); + free( get_item_string(descr, index) ); }
@@ -1807,7 +1805,7 @@ static void LISTBOX_ResetContent( LB_DESCR *descr )
if (!(descr->style & LBS_NODATA)) for (i = descr->nb_items - 1; i >= 0; i--) LISTBOX_DeleteItem(descr, i); - HeapFree( GetProcessHeap(), 0, descr->u.items ); + free( descr->u.items ); descr->nb_items = 0; descr->top_item = 0; descr->selected_item = -1; @@ -2563,7 +2561,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) MEASUREITEMSTRUCT mis; RECT rect;
- if (!(descr = HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) ))) + if (!(descr = calloc( 1, sizeof(*descr) ))) return FALSE;
GetClientRect( hwnd, &rect ); @@ -2572,26 +2570,13 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) descr->style = GetWindowLongW( descr->self, GWL_STYLE ); descr->width = rect.right - rect.left; descr->height = rect.bottom - rect.top; - descr->u.items = NULL; - descr->items_size = 0; - descr->nb_items = 0; - descr->top_item = 0; descr->selected_item = -1; - descr->focus_item = 0; descr->anchor_item = -1; descr->item_height = 1; descr->page_size = 1; descr->column_width = 150; - descr->horz_extent = 0; - descr->horz_pos = 0; - descr->nb_tabs = 0; - descr->tabs = NULL; - descr->wheel_remain = 0; descr->caret_on = !lphc; if (descr->style & LBS_NOSEL) descr->caret_on = FALSE; - descr->in_focus = FALSE; - descr->captured = FALSE; - descr->font = 0; descr->locale = GetUserDefaultLCID(); descr->lphc = lphc;
@@ -2651,7 +2636,7 @@ static BOOL LISTBOX_Destroy( LB_DESCR *descr ) CloseThemeData( theme ); LISTBOX_ResetContent( descr ); SetWindowLongPtrW( descr->self, 0, 0 ); - HeapFree( GetProcessHeap(), 0, descr ); + free( descr ); return TRUE; }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/combo.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/comctl32/combo.c b/dlls/comctl32/combo.c index 5876c2acbb8..321ed811e18 100644 --- a/dlls/comctl32/combo.c +++ b/dlls/comctl32/combo.c @@ -21,6 +21,7 @@ */
#include <stdarg.h> +#include <stdlib.h> #include <string.h>
#define OEMRESOURCE @@ -33,7 +34,6 @@ #include "vssym32.h" #include "commctrl.h" #include "wine/debug.h" -#include "wine/heap.h"
#include "comctl32.h"
@@ -125,7 +125,7 @@ static LRESULT COMBO_NCCreate(HWND hwnd, LONG style) { HEADCOMBO *lphc;
- if (COMBO_Init() && (lphc = heap_alloc_zero(sizeof(*lphc)))) + if (COMBO_Init() && (lphc = calloc(1, sizeof(*lphc)))) { lphc->self = hwnd; SetWindowLongPtrW( hwnd, 0, (LONG_PTR)lphc ); @@ -166,7 +166,7 @@ static LRESULT COMBO_NCDestroy( HEADCOMBO *lphc ) DestroyWindow( lphc->hWndLBox );
SetWindowLongPtrW( lphc->self, 0, 0 ); - heap_free( lphc ); + free( lphc ); }
return 0; @@ -635,7 +635,7 @@ static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint) size = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, id, 0); if (size == LB_ERR) FIXME("LB_ERR probably not handled yet\n"); - if ((pText = heap_alloc((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); @@ -731,7 +731,7 @@ static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint) ReleaseDC( lphc->self, hdc ); }
- heap_free(pText); + free(pText); }
/*********************************************************************** @@ -853,7 +853,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) length = SendMessageW( lphc->hWndEdit, WM_GETTEXTLENGTH, 0, 0 );
if (length > 0) - pText = heap_alloc((length + 1) * sizeof(WCHAR)); + pText = malloc((length + 1) * sizeof(WCHAR));
TRACE("\t edit text length %i\n", length );
@@ -861,7 +861,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) { GetWindowTextW( lphc->hWndEdit, pText, length + 1); idx = SendMessageW(lphc->hWndLBox, LB_FINDSTRING, -1, (LPARAM)pText); - heap_free( pText ); + free( pText ); }
SendMessageW(lphc->hWndLBox, LB_SETCURSEL, bSelect ? idx : -1, 0); @@ -890,7 +890,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index ) length = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, index, 0); if( length != LB_ERR) { - if ((pText = heap_alloc((length + 1) * sizeof(WCHAR)))) + if ((pText = malloc((length + 1) * sizeof(WCHAR)))) SendMessageW(lphc->hWndLBox, LB_GETTEXT, index, (LPARAM)pText); } } @@ -905,7 +905,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index ) if( lphc->wState & CBF_FOCUSED ) SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
- heap_free( pText ); + free( pText ); }
/*********************************************************************** @@ -1319,7 +1319,7 @@ static LRESULT COMBO_GetText( HEADCOMBO *lphc, INT count, LPWSTR buf ) /* 'length' is without the terminating character */ if (length >= count) { - WCHAR *lpBuffer = heap_alloc((length + 1) * sizeof(WCHAR)); + WCHAR *lpBuffer = malloc((length + 1) * sizeof(WCHAR)); if (!lpBuffer) goto error; length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)lpBuffer);
@@ -1329,7 +1329,7 @@ static LRESULT COMBO_GetText( HEADCOMBO *lphc, INT count, LPWSTR buf ) lstrcpynW( buf, lpBuffer, count ); length = count; } - heap_free( lpBuffer ); + free( lpBuffer ); } else length = SendMessageW(lphc->hWndLBox, LB_GETTEXT, idx, (LPARAM)buf);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/tab.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 8943d9dce7c..2c51bced5cb 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -55,6 +55,7 @@ #include <assert.h> #include <stdarg.h> #include <string.h> +#include <stdlib.h>
#include "windef.h" #include "winbase.h" @@ -2596,10 +2597,10 @@ TAB_InsertItemT (TAB_INFO *infoPtr, INT iItem, const TCITEMW *pti, BOOL bUnicode
TAB_DumpItemExternalT(pti, iItem, bUnicode);
- if (!(item = Alloc(TAB_ITEM_SIZE(infoPtr)))) return FALSE; + if (!(item = calloc(1, TAB_ITEM_SIZE(infoPtr)))) return FALSE; if (DPA_InsertPtr(infoPtr->items, iItem, item) == -1) { - Free(item); + free(item); return FALSE; }
@@ -2750,7 +2751,7 @@ TAB_SetItemT (TAB_INFO *infoPtr, INT iItem, LPTCITEMW tabItem, BOOL bUnicode)
if (tabItem->mask & TCIF_TEXT) { - Free(wineItem->pszText); + free(wineItem->pszText); wineItem->pszText = NULL; if (bUnicode) Str_SetPtrW(&wineItem->pszText, tabItem->pszText); @@ -2828,8 +2829,8 @@ static LRESULT TAB_DeleteItem (TAB_INFO *infoPtr, INT iItem)
TAB_InvalidateTabArea(infoPtr); item = TAB_GetItem(infoPtr, iItem); - Free(item->pszText); - Free(item); + free(item->pszText); + free(item); infoPtr->uNumItem--; DPA_DeletePtr(infoPtr->items, iItem);
@@ -2969,7 +2970,7 @@ static LRESULT TAB_Create (HWND hwnd, LPARAM lParam) HFONT hOldFont; DWORD style;
- infoPtr = Alloc (sizeof(TAB_INFO)); + infoPtr = calloc (1, sizeof(*infoPtr));
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
@@ -3079,8 +3080,8 @@ TAB_Destroy (TAB_INFO *infoPtr) DPA_DeletePtr(infoPtr->items, iItem); infoPtr->uNumItem--;
- Free(tab->pszText); - Free(tab); + free(tab->pszText); + free(tab); } DPA_Destroy(infoPtr->items); infoPtr->items = NULL; @@ -3096,7 +3097,7 @@ TAB_Destroy (TAB_INFO *infoPtr)
CloseThemeData (GetWindowTheme (infoPtr->hwnd));
- Free (infoPtr); + free (infoPtr); return 0; }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/datetime.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c index ce154aacbea..fb54d329807 100644 --- a/dlls/comctl32/datetime.c +++ b/dlls/comctl32/datetime.c @@ -35,6 +35,7 @@ #include <stdarg.h> #include <stdio.h> #include <limits.h> +#include <stdlib.h>
#include "windef.h" #include "winbase.h" @@ -350,10 +351,10 @@ DATETIME_SetFormatA (DATETIME_INFO *infoPtr, LPCSTR lpszFormat) if (lpszFormat) { BOOL retval; INT len = MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, NULL, 0); - LPWSTR wstr = Alloc(len * sizeof(WCHAR)); + LPWSTR wstr = calloc(len, sizeof(WCHAR)); if (wstr) MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, wstr, len); retval = DATETIME_SetFormatW (infoPtr, wstr); - Free (wstr); + free (wstr); return retval; } else @@ -1605,7 +1606,7 @@ DATETIME_SetFont (DATETIME_INFO *infoPtr, HFONT font, BOOL repaint) static LRESULT DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs) { - DATETIME_INFO *infoPtr = Alloc (sizeof(DATETIME_INFO)); + DATETIME_INFO *infoPtr = calloc (1, sizeof(*infoPtr)); STYLESTRUCT ss = { 0, lpcs->style };
if (!infoPtr) return -1; @@ -1657,10 +1658,10 @@ DATETIME_Destroy (DATETIME_INFO *infoPtr) if (infoPtr->hMonthCal) DestroyWindow(infoPtr->hMonthCal); SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 ); /* clear infoPtr */ - Free (infoPtr->buflen); - Free (infoPtr->fieldRect); - Free (infoPtr->fieldspec); - Free (infoPtr); + free (infoPtr->buflen); + free (infoPtr->fieldRect); + free (infoPtr->fieldspec); + free (infoPtr); return 0; }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/draglist.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/draglist.c b/dlls/comctl32/draglist.c index 183e4e82beb..b0954365594 100644 --- a/dlls/comctl32/draglist.c +++ b/dlls/comctl32/draglist.c @@ -30,6 +30,7 @@ */
#include <stdarg.h> +#include <stdlib.h>
#include "windef.h" #include "winbase.h" @@ -186,7 +187,7 @@ DragList_SubclassWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, break; case WM_NCDESTROY: RemoveWindowSubclass(hwnd, DragList_SubclassWindowProc, DRAGLIST_SUBCLASSID); - Free(data); + free(data); break; } return DefSubclassProc(hwnd, uMsg, wParam, lParam); @@ -203,7 +204,7 @@ DragList_SubclassWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, */ BOOL WINAPI MakeDragList (HWND hwndLB) { - DRAGLISTDATA *data = Alloc(sizeof(DRAGLISTDATA)); + DRAGLISTDATA *data = calloc(1, sizeof(*data));
TRACE("(%p)\n", hwndLB);
This merge request was approved by Zhiyi Zhang.
Rémi Bernon (@rbernon) commented about dlls/comctl32/datetime.c:
if (infoPtr->hMonthCal) DestroyWindow(infoPtr->hMonthCal); SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 ); /* clear infoPtr */
- Free (infoPtr->buflen);
- Free (infoPtr->fieldRect);
- Free (infoPtr->fieldspec);
- Free (infoPtr);
- free (infoPtr->buflen);
- free (infoPtr->fieldRect);
- free (infoPtr->fieldspec);
- free (infoPtr);
Most of these are still allocated with Alloc above.
Rémi Bernon (@rbernon) commented about dlls/comctl32/tab.c:
DPA_DeletePtr(infoPtr->items, iItem); infoPtr->uNumItem--;
Free(tab->pszText);
Free(tab);
free(tab->pszText);
Same thing here.
Rémi Bernon (@rbernon) commented about dlls/comctl32/tab.c:
TAB_InvalidateTabArea(infoPtr); item = TAB_GetItem(infoPtr, iItem);
- Free(item->pszText);
- Free(item);
- free(item->pszText);
This causes a mismatched heap free, in the same way as in listview. You need to use wcsdup / strdupAW as introduced by https://gitlab.winehq.org/wine/wine/-/merge_requests/1633.
This merge request was closed by Nikolay Sivov.