http://bugs.winehq.org/show_bug.cgi?id=25463
--- Comment #17 from Jacek Caban jacek@codeweavers.com 2011-01-10 15:51:58 CST --- Thanks for the patch. I really hope we can avoid old-style UrlUnescape call here. I was expecting IUri APIs to allow us that, but I did some tests and it seems like it won't help here. Perhaps itss is responsible for unescaping?
Given that UrlUnescape is not related to the rest of the patch, these should be two separated patches. Sorry for giving you wrong pointer about IInternetProtocolEx, it won't help for this particular bug at all, but since you've already written it, let's get it to the tree. Here are a few comments:
-static HRESULT WINAPI MkProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, +static HRESULT WINAPI MkProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri,
Please keep the order of function implementation matching vtbl layout. It means that StartEx should be the last implemented function. If you want to reduce patch size, you can duplicate Start code (with changes for using IUri) inside the new StartEx function and forward Start to StartEx in a separated patch.
+ BSTR szUrl, szPathTmp, szPath = NULL;
Please don't use Hungarian notation. url, path and path_tmp are would be preferable names.
+ hres = IUri_GetDisplayUri(pUri, &szUrl); + if(FAILED(hres)) + return hres; + hres = IUri_GetPath(pUri, &szPathTmp); + if(FAILED(hres)) + goto done;
If you moved these calls to the place there you need their results and free resources as soon as they are no longer needed, you will avoid some gotos and holding useless data.
progid = heap_alloc((ptr-ptr2+1)*sizeof(WCHAR)); memcpy(progid, ptr2, (ptr-ptr2)*sizeof(WCHAR));
Since you own the memory of path here, you can avoid this allocation.
+ szPath = heap_alloc(path_size); + hres = UrlUnescapeW((LPWSTR)szPathTmp, szPath, &path_size, 0); + SysFreeString(szPathTmp);
Let's leave unescaping for later patch.