dplayx: Simplify the creation of a IDPLobbySPImpl COM object.

This commit is contained in:
Michael Stefaniuc 2013-09-03 23:24:58 +02:00 committed by Alexandre Julliard
parent 56e1e6aa7f
commit 30c55f3547
3 changed files with 24 additions and 37 deletions

View File

@ -187,8 +187,7 @@ static BOOL DP_CreateDirectPlay2( LPVOID lpDP )
sizeof( *This->dp2->dplspData.lpCB ) );
This->dp2->dplspData.lpCB->dwSize = sizeof( *This->dp2->dplspData.lpCB );
if( FAILED( DPLSP_CreateInterface( &IID_IDPLobbySP,
(LPVOID*)&This->dp2->dplspData.lpISP, This ) )
if( FAILED( dplobbysp_create( &IID_IDPLobbySP, (void**)&This->dp2->dplspData.lpISP, This ) )
)
{
/* FIXME: Memory leak */

View File

@ -209,6 +209,6 @@ 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 DPLSP_CreateInterface( REFIID riid, void **ppvObj, IDirectPlayImpl *dp ) DECLSPEC_HIDDEN;
extern HRESULT dplobbysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp ) DECLSPEC_HIDDEN;
#endif /* __WINE_DPLAY_GLOBAL_INCLUDED */

View File

@ -38,40 +38,6 @@ static inline IDPLobbySPImpl *impl_from_IDPLobbySP(IDPLobbySP *iface)
return CONTAINING_RECORD(iface, IDPLobbySPImpl, IDPLobbySP_iface);
}
/* Forward declaration of virtual tables */
static const IDPLobbySPVtbl dpLobbySPVT;
HRESULT DPLSP_CreateInterface( REFIID riid, void **ppvObj, IDirectPlayImpl *dp )
{
TRACE( " for %s\n", debugstr_guid( riid ) );
*ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof( IDPLobbySPImpl ) );
if( *ppvObj == NULL )
{
return DPERR_OUTOFMEMORY;
}
if( IsEqualGUID( &IID_IDPLobbySP, riid ) )
{
IDPLobbySPImpl *This = *ppvObj;
This->IDPLobbySP_iface.lpVtbl = &dpLobbySPVT;
This->dplay = dp;
}
else
{
/* Unsupported interface */
HeapFree( GetProcessHeap(), 0, *ppvObj );
*ppvObj = NULL;
return E_NOINTERFACE;
}
IDPLobbySP_AddRef( (LPDPLOBBYSP)*ppvObj );
return S_OK;
}
static HRESULT WINAPI IDPLobbySPImpl_QueryInterface( IDPLobbySP *iface, REFIID riid,
void **ppv )
{
@ -260,3 +226,25 @@ static const IDPLobbySPVtbl dpLobbySPVT =
IDPLobbySPImpl_SetSPDataPointer,
IDPLobbySPImpl_StartSession
};
HRESULT dplobbysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp )
{
IDPLobbySPImpl *obj;
HRESULT hr;
TRACE( "(%s, %p)\n", debugstr_guid( riid ), ppv );
*ppv = NULL;
obj = HeapAlloc( GetProcessHeap(), 0, sizeof( *obj ) );
if ( !obj )
return DPERR_OUTOFMEMORY;
obj->IDPLobbySP_iface.lpVtbl = &dpLobbySPVT;
obj->ref = 0;
obj->dplay = dp;
hr = IDPLobbySP_QueryInterface( &obj->IDPLobbySP_iface, riid, ppv );
IDPLobbySP_Release( &obj->IDPLobbySP_iface );
return hr;
}