From 17339f4f94b9e76d52957e10a636627a56ab2517 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 7 Apr 2015 12:55:48 +0300 Subject: [PATCH] shell32: Cleanup IShellItem creation calls. --- dlls/shell32/shellitem.c | 45 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/dlls/shell32/shellitem.c b/dlls/shell32/shellitem.c index d8cb6a8ebbe..a4103812b38 100644 --- a/dlls/shell32/shellitem.c +++ b/dlls/shell32/shellitem.c @@ -548,7 +548,6 @@ HRESULT WINAPI IShellItem_Constructor(IUnknown *pUnkOuter, REFIID riid, void **p HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi) { - ShellItem *This; LPITEMIDLIST new_pidl; HRESULT ret; @@ -597,16 +596,9 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, return E_OUTOFMEMORY; } - ret = IShellItem_Constructor(NULL, &IID_IShellItem, (void**)&This); - if (This) - { - *ppsi = (IShellItem*)&This->IShellItem2_iface; - This->pidl = new_pidl; - } - else - { - ILFree(new_pidl); - } + ret = SHCreateItemFromIDList(new_pidl, &IID_IShellItem, (void**)ppsi); + ILFree(new_pidl); + return ret; } @@ -621,37 +613,34 @@ HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath, ret = SHParseDisplayName(pszPath, pbc, &pidl, 0, NULL); if(SUCCEEDED(ret)) { - ShellItem *This; - ret = IShellItem_Constructor(NULL, riid, (void**)&This); - - if(SUCCEEDED(ret)) - { - This->pidl = pidl; - *ppv = (void*)This; - } - else - { - ILFree(pidl); - } + ret = SHCreateItemFromIDList(pidl, riid, ppv); + ILFree(pidl); } return ret; } HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv) { - ShellItem *psiimpl; + IPersistIDList *persist; HRESULT ret; if(!pidl) return E_INVALIDARG; - ret = IShellItem_Constructor(NULL, riid, ppv); - if(SUCCEEDED(ret)) + *ppv = NULL; + ret = IShellItem_Constructor(NULL, &IID_IPersistIDList, (void**)&persist); + if(FAILED(ret)) + return ret; + + ret = IPersistIDList_SetIDList(persist, pidl); + if(FAILED(ret)) { - psiimpl = (ShellItem*)*ppv; - psiimpl->pidl = ILClone(pidl); + IPersistIDList_Release(persist); + return ret; } + ret = IPersistIDList_QueryInterface(persist, riid, ppv); + IPersistIDList_Release(persist); return ret; }