Commit 8784d47c authored by Felix Nawothnig's avatar Felix Nawothnig Committed by Alexandre Julliard

comctl32: Remove redundant NULL checks before Free() calls.

parent 43c0ce16
......@@ -227,7 +227,7 @@ COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr)
if (astr && hdr->ceItem.pszText == (LPWSTR)astr)
hdr->ceItem.pszText = wstr;
if (astr) Free(astr);
Free(astr);
return ret;
}
......@@ -278,7 +278,7 @@ static void COMBOEX_FreeText (CBE_ITEMDATA *item)
{
if (is_textW(item->pszText)) Free(item->pszText);
item->pszText = 0;
if (item->pszTemp) Free(item->pszTemp);
Free(item->pszTemp);
item->pszTemp = 0;
}
......@@ -327,7 +327,7 @@ static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
COMBOEX_FreeText(item);
item->pszText = buf;
} else {
if (item->pszTemp) Free(item->pszTemp);
Free(item->pszTemp);
item->pszTemp = buf;
}
text = buf;
......@@ -701,7 +701,7 @@ static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
}
ret = COMBOEX_InsertItemW(infoPtr, &citW);
if (wstr) Free(wstr);
Free(wstr);
return ret;
}
......@@ -825,7 +825,7 @@ static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
}
ret = COMBOEX_SetItemW(infoPtr, &citW);
if (wstr) Free(wstr);
Free(wstr);
return ret;
}
......
......@@ -351,10 +351,9 @@ void WINAPI FreeMRUList (HANDLE hMRUList)
MRU_SaveChanged( mp );
}
for(i=0; i<mp->extview.nMaxItems; i++) {
if (mp->array[i])
Free(mp->array[i]);
}
for(i=0; i<mp->extview.nMaxItems; i++)
Free(mp->array[i]);
Free(mp->realMRU);
Free(mp->array);
Free(mp->extview.lpszSubKey);
......@@ -422,8 +421,7 @@ INT WINAPI FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData,
}
}
}
if(dataA)
Free(dataA);
Free(dataA);
if (i < mp->cursize)
ret = i;
else
......
......@@ -113,14 +113,6 @@ static LRESULT HEADER_SendCtrlCustomDraw(HWND hwnd, DWORD dwDrawStage, HDC hdc,
static const WCHAR themeClass[] = {'H','e','a','d','e','r',0};
static WCHAR emptyString[] = {0};
static void HEADER_DisposeItem(HEADER_ITEM *lpItem)
{
if (lpItem->pszText)
{
Free(lpItem->pszText);
}
}
static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, UINT mask, HDITEMW *phdi, BOOL fUnicode)
{
if (mask & HDI_UNSUPPORTED_FIELDS)
......@@ -149,11 +141,8 @@ static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, UINT mask, HDITEMW *
if (mask & HDI_TEXT)
{
if (lpItem->pszText)
{
Free(lpItem->pszText);
lpItem->pszText = NULL;
}
Free(lpItem->pszText);
lpItem->pszText = NULL;
if (phdi->pszText != LPSTR_TEXTCALLBACKW) /* covers != TEXTCALLBACKA too */
{
......@@ -1093,7 +1082,7 @@ HEADER_DeleteItem (HWND hwnd, WPARAM wParam)
TRACE("%d: order=%d, iOrder=%d, ->iOrder=%d\n", i, infoPtr->order[i], infoPtr->items[i].iOrder, infoPtr->items[infoPtr->order[i]].iOrder);
iOrder = infoPtr->items[iItem].iOrder;
HEADER_DisposeItem(&infoPtr->items[iItem]);
Free(infoPtr->items[iItem].pszText);
infoPtr->uNumItem--;
memmove(&infoPtr->items[iItem], &infoPtr->items[iItem + 1],
......@@ -1422,7 +1411,7 @@ HEADER_SetItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
HEADER_CopyHDItemForNotify(infoPtr, &hdNotify, phdi, bUnicode, &pvScratch);
if (HEADER_SendNotifyWithHDItemT(hwnd, HDN_ITEMCHANGINGW, nItem, &hdNotify))
{
if (pvScratch) Free(pvScratch);
Free(pvScratch);
return FALSE;
}
......@@ -1439,8 +1428,7 @@ HEADER_SetItemT (HWND hwnd, INT nItem, LPHDITEMW phdi, BOOL bUnicode)
InvalidateRect(hwnd, NULL, FALSE);
if (pvScratch != NULL)
Free(pvScratch);
Free(pvScratch);
return TRUE;
}
......@@ -1517,13 +1505,12 @@ HEADER_NCDestroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (infoPtr->items) {
lpItem = infoPtr->items;
for (nItem = 0; nItem < infoPtr->uNumItem; nItem++, lpItem++) {
HEADER_DisposeItem(lpItem);
Free(lpItem->pszText);
}
Free (infoPtr->items);
}
if (infoPtr->order)
Free(infoPtr->order);
Free(infoPtr->order);
if (infoPtr->himl)
ImageList_Destroy (infoPtr->himl);
......
......@@ -9964,8 +9964,7 @@ static LRESULT EditLblWndProcT(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara
}
LISTVIEW_EndEditLabelT(infoPtr, buffer, isW);
if (buffer) Free(buffer);
Free(buffer);
}
SendMessageW(hwnd, WM_CLOSE, 0, 0);
......
......@@ -1909,10 +1909,9 @@ static LRESULT
MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr)
{
/* free month calendar info data */
if(infoPtr->monthdayState)
Free(infoPtr->monthdayState);
Free(infoPtr->monthdayState);
SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0);
CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
Free(infoPtr);
......
......@@ -1494,8 +1494,7 @@ static BOOL PROPSHEET_CreatePage(HWND hwndParent,
ppshpage->pfnDlgProc,
(LPARAM)ppshpage);
/* Free a no more needed copy */
if(temp)
Free(temp);
Free(temp);
psInfo->proppage[index].hwndPage = hwndPage;
......
......@@ -117,14 +117,8 @@ static VOID SYSLINK_FreeDocItem (PDOC_ITEM DocItem)
{
if(DocItem->Type == slLink)
{
if (DocItem->u.Link.szID != NULL)
{
Free(DocItem->u.Link.szID);
}
if (DocItem->u.Link.szUrl != NULL)
{
Free(DocItem->u.Link.szUrl);
}
Free(DocItem->u.Link.szID);
Free(DocItem->u.Link.szUrl);
}
/* we don't free Text because it's just a pointer to a character in the
......@@ -1081,11 +1075,7 @@ static LRESULT SYSLINK_SetItem (SYSLINK_INFO *infoPtr, PLITEM Item)
}
else
{
if (szId)
{
Free(szId);
}
Free(szId);
ERR("Unable to allocate memory for link url\n");
return FALSE;
}
......@@ -1093,19 +1083,13 @@ static LRESULT SYSLINK_SetItem (SYSLINK_INFO *infoPtr, PLITEM Item)
if(Item->mask & LIF_ITEMID)
{
if(di->u.Link.szID)
{
Free(di->u.Link.szID);
}
Free(di->u.Link.szID);
di->u.Link.szID = szId;
}
if(Item->mask & LIF_URL)
{
if(di->u.Link.szUrl)
{
Free(di->u.Link.szUrl);
}
Free(di->u.Link.szUrl);
di->u.Link.szUrl = szUrl;
}
......
......@@ -2840,12 +2840,9 @@ static LRESULT TAB_DeleteItem (TAB_INFO *infoPtr, INT iItem)
{
TAB_ITEM *item = TAB_GetItem(infoPtr, iItem);
LPBYTE oldItems = (LPBYTE)infoPtr->items;
TAB_InvalidateTabArea(infoPtr);
if (item->pszText)
Free(item->pszText);
TAB_InvalidateTabArea(infoPtr);
Free(item->pszText);
infoPtr->uNumItem--;
if (!infoPtr->uNumItem)
......
......@@ -820,8 +820,7 @@ TREEVIEW_UpdateDispInfo(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
(LPSTR)callback.item.pszText, -1,
wineItem->pszText, buflen/sizeof(WCHAR));
wineItem->cchTextMax = buflen/sizeof(WCHAR);
if (oldText)
Free(oldText);
Free(oldText);
}
}
}
......@@ -1484,7 +1483,7 @@ TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem)
infoPtr->uNumItems--;
if (wineItem->pszText && wineItem->pszText != LPSTR_TEXTCALLBACKW)
if (wineItem->pszText != LPSTR_TEXTCALLBACKW)
Free(wineItem->pszText);
TREEVIEW_FreeItem(infoPtr, wineItem);
......
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