Commit 30c55f35 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dplayx: Simplify the creation of a IDPLobbySPImpl COM object.

parent 56e1e6aa
......@@ -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 */
......
......@@ -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 */
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment