[PATCH 2/2] wined3d: Re-use old wined3d_private_data structures if the size matches.
Stefan Dösinger
stefan at codeweavers.com
Fri Mar 14 08:50:34 CDT 2014
When replacing an IUnknown with another IUnknown also make sure to
AddRef the new one before releasing the old one.
---
include/wine/wined3d.h | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 74ff3d1..111b52d 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2320,10 +2320,23 @@ static inline HRESULT wined3d_private_store_set_private_data(struct wined3d_priv
ptr = &data;
}
- if (!(d = HeapAlloc(GetProcessHeap(), 0,
+ if ((old = wined3d_private_store_get_private_data(store, guid)) && old->size == data_size)
+ {
+ IUnknown *release = NULL;
+ if (old->flags & WINED3DSPD_IUNKNOWN)
+ release = old->content.object;
+ memcpy(old->content.data, ptr, data_size);
+ old->flags = flags;
+ if (flags & WINED3DSPD_IUNKNOWN)
+ IUnknown_AddRef(old->content.object);
+ if (release)
+ IUnknown_Release(release);
+ return WINED3D_OK;
+ }
+ else if (!(d = HeapAlloc(GetProcessHeap(), 0,
FIELD_OFFSET(struct wined3d_private_data, content.data[data_size]))))
return E_OUTOFMEMORY;
- old = wined3d_private_store_get_private_data(store, guid);
+
if (old)
wined3d_private_store_free_private_data(store, old);
--
1.8.3.2
More information about the wine-patches
mailing list