diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 94ba8447faf..20899d53745 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -173,9 +173,7 @@ static BOOL DP_CreateDirectPlay2( LPVOID lpDP ) This->dp2->spData.lpCB->dwVersion = DPSP_MAJORVERSION; /* This is the pointer to the service provider */ - if( FAILED( DPSP_CreateInterface( &IID_IDirectPlaySP, - (LPVOID*)&This->dp2->spData.lpISP, This ) ) - ) + if ( FAILED( dplaysp_create( &IID_IDirectPlaySP, (void**)&This->dp2->spData.lpISP, This ) ) ) { /* FIXME: Memory leak */ return FALSE; diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index dca6396ab44..7def46bc2dd 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -208,7 +208,7 @@ extern LPVOID DPSP_CreateSPPlayerData(void) DECLSPEC_HIDDEN; extern HRESULT dplay_create( REFIID riid, void **ppv ) DECLSPEC_HIDDEN; extern HRESULT dplobby_create( REFIID riid, void **ppv ) DECLSPEC_HIDDEN; -extern HRESULT DPSP_CreateInterface( REFIID riid, void **ppvObj, IDirectPlayImpl *dp ) DECLSPEC_HIDDEN; +extern HRESULT dplaysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp ) DECLSPEC_HIDDEN; extern HRESULT dplobbysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp ) DECLSPEC_HIDDEN; #endif /* __WINE_DPLAY_GLOBAL_INCLUDED */ diff --git a/dlls/dplayx/dplaysp.c b/dlls/dplayx/dplaysp.c index e8269dfb076..25cb7c40cb9 100644 --- a/dlls/dplayx/dplaysp.c +++ b/dlls/dplayx/dplaysp.c @@ -44,9 +44,6 @@ typedef struct IDirectPlaySPImpl IDirectPlayImpl *dplay; /* FIXME: This should perhaps be iface not impl */ } IDirectPlaySPImpl; -/* Forward declaration of virtual tables */ -static const IDirectPlaySPVtbl directPlaySPVT; - /* This structure is passed to the DP object for safe keeping */ typedef struct tagDP_SPPLAYERDATA { @@ -57,37 +54,6 @@ typedef struct tagDP_SPPLAYERDATA DWORD dwPlayerRemoteDataSize; } DP_SPPLAYERDATA, *LPDP_SPPLAYERDATA; -/* Create the SP interface */ -HRESULT DPSP_CreateInterface( REFIID riid, void **ppvObj, IDirectPlayImpl *dp ) -{ - TRACE( " for %s\n", debugstr_guid( riid ) ); - - *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof( IDirectPlaySPImpl ) ); - - if( *ppvObj == NULL ) - { - return DPERR_OUTOFMEMORY; - } - - if( IsEqualGUID( &IID_IDirectPlaySP, riid ) ) - { - IDirectPlaySPImpl *This = *ppvObj; - This->IDirectPlaySP_iface.lpVtbl = &directPlaySPVT; - This->dplay = dp; - } - else - { - /* Unsupported interface */ - HeapFree( GetProcessHeap(), 0, *ppvObj ); - *ppvObj = NULL; - - return E_NOINTERFACE; - } - - IDirectPlaySP_AddRef( (LPDIRECTPLAYSP)*ppvObj ); - return S_OK; -} static inline IDirectPlaySPImpl *impl_from_IDirectPlaySP( IDirectPlaySP *iface ) { @@ -717,6 +683,27 @@ static const IDirectPlaySPVtbl directPlaySPVT = IDirectPlaySPImpl_SendComplete }; +HRESULT dplaysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp ) +{ + IDirectPlaySPImpl *obj; + HRESULT hr; + + TRACE( "(%s, %p)\n", debugstr_guid( riid ), ppv ); + + *ppv = NULL; + obj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *obj ) ); + if ( !obj ) + return DPERR_OUTOFMEMORY; + + obj->IDirectPlaySP_iface.lpVtbl = &directPlaySPVT; + obj->ref = 1; + obj->dplay = dp; + + hr = IDirectPlaySP_QueryInterface( &obj->IDirectPlaySP_iface, riid, ppv ); + IDirectPlaySP_Release( &obj->IDirectPlaySP_iface ); + + return hr; +} /* DP external interfaces to call into DPSP interface */