[3/3] msxml3: No need to keep a reference to a temporarily used stream
Nikolay Sivov
nsivov at codeweavers.com
Tue Nov 27 02:47:33 CST 2012
This was added with initial implementation of IPersistStreamInit in
http://source.winehq.org/git/wine.git/commit/7ec06c8442c151a97688b35e0a8012ce5dd8b6de
and I don't really see a reason why, but CC'ing author just in case.
-------------- next part --------------
>From c2f871364c15b80890f429006d2326b5b9e1edf1 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon, 26 Nov 2012 23:32:57 -0500
Subject: [PATCH 3/4] No need to keep a reference to a temporarily used stream
---
dlls/msxml3/domdoc.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index c3144ce..52b41a7 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -132,9 +132,6 @@ struct domdoc
bsc_t *bsc;
HRESULT error;
- /* IPersistStream */
- IStream *stream;
-
/* IObjectWithSite*/
IUnknown *site;
@@ -722,34 +719,31 @@ static HRESULT domdoc_load_from_stream(domdoc *doc, ISequentialStream *stream)
{
DWORD read, written, len;
xmlDocPtr xmldoc = NULL;
+ IStream *hstream;
HGLOBAL hglobal;
BYTE buf[4096];
HRESULT hr;
char *ptr;
- if (doc->stream)
- {
- IStream_Release(doc->stream);
- doc->stream = NULL;
- }
-
- hr = CreateStreamOnHGlobal(NULL, TRUE, &doc->stream);
+ hstream = NULL;
+ hr = CreateStreamOnHGlobal(NULL, TRUE, &hstream);
if (FAILED(hr))
return hr;
do
{
ISequentialStream_Read(stream, buf, sizeof(buf), &read);
- hr = IStream_Write(doc->stream, buf, read, &written);
+ hr = IStream_Write(hstream, buf, read, &written);
} while(SUCCEEDED(hr) && written != 0 && read != 0);
if (FAILED(hr))
{
ERR("failed to copy stream 0x%08x\n", hr);
+ IStream_Release(hstream);
return hr;
}
- hr = GetHGlobalFromStream(doc->stream, &hglobal);
+ hr = GetHGlobalFromStream(hstream, &hglobal);
if (FAILED(hr))
return hr;
@@ -922,8 +916,6 @@ static ULONG WINAPI domdoc_Release( IXMLDOMDocument3 *iface )
if (This->site)
IUnknown_Release( This->site );
destroy_xmlnode(&This->node);
- if (This->stream)
- IStream_Release(This->stream);
for (eid = 0; eid < EVENTID_LAST; eid++)
if (This->events[eid]) IDispatch_Release(This->events[eid]);
@@ -3493,7 +3485,6 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document)
doc->resolving = 0;
doc->properties = properties_from_xmlDocPtr(xmldoc);
doc->error = S_OK;
- doc->stream = NULL;
doc->site = NULL;
doc->safeopt = 0;
doc->bsc = NULL;
--
1.7.10.4
More information about the wine-patches
mailing list