Hi Hans, On 5/25/22 13:43, Hans Leidekker wrote:
+struct storage { + IXMLDOMDocument *doc; + HANDLE mutex; +}; + +static void close_storage(struct storage *storage) +{ + if(storage->doc) + IXMLDOMDocument_Release(storage->doc); + ReleaseMutex(storage->mutex); + CloseHandle(storage->mutex); + heap_free(storage); +} + +static HRESULT open_storage(const WCHAR *filename, struct storage **ret) +{ + struct storage *storage; + HRESULT hres = E_OUTOFMEMORY; + VARIANT var; + VARIANT_BOOL success; + WCHAR *mutexname, *ptr, *path = NULL; + + storage = heap_alloc_zero(sizeof(*storage)); + if(!storage) + return E_OUTOFMEMORY; + + mutexname = build_mutexname(filename); + if(!mutexname) + goto done; + + storage->mutex = CreateMutexW(NULL, FALSE, mutexname); + heap_free(mutexname); + if(!storage->mutex) { + hres = HRESULT_FROM_WIN32(GetLastError()); + goto done; + }
This seems less than optimal. Maybe we could store mutex handle in HTMLStorage itself instead of reopening it on each call? open_storage() could then just return IXMLDOMDocument, avoiding storage struct allocation. Thanks, Jacek