From a8616b7fcb75e694b45c15c48a4d9550c8aca9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ri=C4=8Dardas=20Barkauskas?= Date: Mon, 3 Oct 2011 17:14:08 -0500 Subject: [PATCH] ddraw: Use unsafe_impl_from_IDirectDrawPalette for application provided interfaces. --- dlls/ddraw/ddraw_private.h | 2 ++ dlls/ddraw/palette.c | 7 +++++++ dlls/ddraw/surface.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 0572172a238..7898d28bdf2 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -369,6 +369,8 @@ struct IDirectDrawPaletteImpl IUnknown *ifaceToRelease; }; +IDirectDrawPaletteImpl *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface) DECLSPEC_HIDDEN; + HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette, IDirectDrawImpl *ddraw, DWORD flags, PALETTEENTRY *entries) DECLSPEC_HIDDEN; diff --git a/dlls/ddraw/palette.c b/dlls/ddraw/palette.c index b68cf82d4f0..ff784119d9e 100644 --- a/dlls/ddraw/palette.c +++ b/dlls/ddraw/palette.c @@ -258,6 +258,13 @@ static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl = IDirectDrawPaletteImpl_SetEntries }; +IDirectDrawPaletteImpl *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface) +{ + if (!iface) return NULL; + assert(iface->lpVtbl == &ddraw_palette_vtbl); + return CONTAINING_RECORD(iface, IDirectDrawPaletteImpl, lpVtbl); +} + HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette, IDirectDrawImpl *ddraw, DWORD flags, PALETTEENTRY *entries) { diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 4cd14528d4d..7c70f0fc2a5 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -4288,7 +4288,7 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface); IDirectDrawPalette *oldPal; IDirectDrawSurfaceImpl *surf; - IDirectDrawPaletteImpl *PalImpl = (IDirectDrawPaletteImpl *)Pal; + IDirectDrawPaletteImpl *PalImpl = unsafe_impl_from_IDirectDrawPalette(Pal); HRESULT hr; TRACE("iface %p, palette %p.\n", iface, Pal);