[PATCH 3/4] quartz: Use unsafe_impl_from_IMediaSample() instead of a cast

Michael Stefaniuc mstefani at redhat.de
Mon Jul 2 17:19:52 CDT 2012


---
 dlls/quartz/memallocator.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/quartz/memallocator.c b/dlls/quartz/memallocator.c
index df4cf63..cc700c2 100644
--- a/dlls/quartz/memallocator.c
+++ b/dlls/quartz/memallocator.c
@@ -70,6 +70,7 @@ static inline BaseMemAllocator *impl_from_IMemAllocator(IMemAllocator *iface)
 
 static const IMemAllocatorVtbl BaseMemAllocator_VTable;
 static const IMediaSample2Vtbl StdMediaSample2_VTable;
+static inline StdMediaSample2 *unsafe_impl_from_IMediaSample(IMediaSample * iface);
 
 #define AM_SAMPLE2_PROP_SIZE_WRITABLE FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer)
 
@@ -356,9 +357,9 @@ static HRESULT WINAPI BaseMemAllocator_GetBuffer(IMemAllocator * iface, IMediaSa
 static HRESULT WINAPI BaseMemAllocator_ReleaseBuffer(IMemAllocator * iface, IMediaSample * pSample)
 {
     BaseMemAllocator *This = impl_from_IMemAllocator(iface);
-    StdMediaSample2 * pStdSample = (StdMediaSample2 *)pSample;
+    StdMediaSample2 * pStdSample = unsafe_impl_from_IMediaSample(pSample);
     HRESULT hr = S_OK;
-    
+
     TRACE("(%p)->(%p)\n", This, pSample);
 
     /* FIXME: make sure that sample is currently on the used list */
@@ -791,6 +792,16 @@ static const IMediaSample2Vtbl StdMediaSample2_VTable =
     StdMediaSample2_SetProperties
 };
 
+static inline StdMediaSample2 *unsafe_impl_from_IMediaSample(IMediaSample * iface)
+{
+    IMediaSample2 *iface2 = (IMediaSample2 *)iface;
+
+    if (!iface)
+        return NULL;
+    assert(iface2->lpVtbl == &StdMediaSample2_VTable);
+    return impl_from_IMediaSample2(iface2);
+}
+
 typedef struct StdMemAllocator
 {
     BaseMemAllocator base;
-- 
1.7.6.5



More information about the wine-patches mailing list