From 8784d47cba60d7daf5aef5e92eb4e9ff58de4c81 Mon Sep 17 00:00:00 2001 From: Felix Nawothnig <flexo@holycrap.org> Date: Tue, 13 Feb 2007 21:18:24 +0100 Subject: [PATCH] comctl32: Remove redundant NULL checks before Free() calls. --- dlls/comctl32/comboex.c | 10 +++++----- dlls/comctl32/comctl32undoc.c | 10 ++++------ dlls/comctl32/header.c | 27 +++++++-------------------- dlls/comctl32/listview.c | 3 +-- dlls/comctl32/monthcal.c | 5 ++--- dlls/comctl32/propsheet.c | 3 +-- dlls/comctl32/syslink.c | 26 +++++--------------------- dlls/comctl32/tab.c | 7 ++----- dlls/comctl32/treeview.c | 5 ++--- 9 files changed, 29 insertions(+), 67 deletions(-) diff --git a/dlls/comctl32/comboex.c b/dlls/comctl32/comboex.c index 2499b800894..1c354bd4804 100644 --- a/dlls/comctl32/comboex.c +++ b/dlls/comctl32/comboex.c @@ -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; } diff --git a/dlls/comctl32/comctl32undoc.c b/dlls/comctl32/comctl32undoc.c index b8c8ef8d480..d18390e20cf 100644 --- a/dlls/comctl32/comctl32undoc.c +++ b/dlls/comctl32/comctl32undoc.c @@ -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 diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index 73b10950a26..2915389e30b 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -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); diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 208d28b6f89..b14537a2826 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -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); diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 5baf7887047..53a8e5c158b 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -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); diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index f4ead78cfc0..e9e4affdd0f 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -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; diff --git a/dlls/comctl32/syslink.c b/dlls/comctl32/syslink.c index 237ed27de44..304e4072ab2 100644 --- a/dlls/comctl32/syslink.c +++ b/dlls/comctl32/syslink.c @@ -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; } diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 7ecd977b02e..cbb4cdd7144 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -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); - + Free(item->pszText); infoPtr->uNumItem--; if (!infoPtr->uNumItem) diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index b89f2de3afa..1130daa8e84 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -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);