Michael Stefaniuc : dplayx: Move the lock into the DirectPlay object.

Alexandre Julliard julliard at winehq.org
Tue Apr 2 13:38:35 CDT 2013


Module: wine
Branch: master
Commit: 526851f5df095fb02b594f8a6a26c70bac50a132
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=526851f5df095fb02b594f8a6a26c70bac50a132

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Fri Mar 29 16:48:24 2013 +0100

dplayx: Move the lock into the DirectPlay object.

---

 dlls/dplayx/dplay.c           |   36 +++++-------------------------------
 dlls/dplayx/dplay_global.h    |    7 +------
 dlls/dplayx/dplayx_messages.c |    8 ++++----
 3 files changed, 10 insertions(+), 41 deletions(-)

diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index 8220421..9f766de 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -227,33 +227,6 @@ static inline IDirectPlayImpl *impl_from_IDirectPlay4( IDirectPlay4 *iface )
     return CONTAINING_RECORD( iface, IDirectPlayImpl, IDirectPlay4_iface );
 }
 
-static BOOL DP_CreateIUnknown( LPVOID lpDP )
-{
-  IDirectPlay2AImpl *This = lpDP;
-
-  This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
-  if ( This->unk == NULL )
-  {
-    return FALSE;
-  }
-
-  InitializeCriticalSection( &This->unk->DP_lock );
-  This->unk->DP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlay2AImpl*->DirectPlayIUnknownData*->DP_lock");
-
-  return TRUE;
-}
-
-static BOOL DP_DestroyIUnknown( LPVOID lpDP )
-{
-  IDirectPlay2AImpl *This = lpDP;
-
-  This->unk->DP_lock.DebugInfo->Spare[0] = 0;
-  DeleteCriticalSection( &This->unk->DP_lock );
-  HeapFree( GetProcessHeap(), 0, This->unk );
-
-  return TRUE;
-}
-
 static BOOL DP_CreateDirectPlay2( LPVOID lpDP )
 {
   IDirectPlay2AImpl *This = lpDP;
@@ -418,8 +391,10 @@ HRESULT DP_CreateInterface
   }
 
   /* Initialize it */
-  if ( DP_CreateIUnknown( This ) && DP_CreateDirectPlay2( This ) )
+  if ( DP_CreateDirectPlay2( This ) )
   {
+    InitializeCriticalSection( &This->lock );
+    This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlayImpl.lock");
     IDirectPlayX_AddRef( (LPDIRECTPLAY2A)*ppvObj );
 
     return S_OK;
@@ -427,8 +402,6 @@ HRESULT DP_CreateInterface
 
   /* Initialize failed, destroy it */
   DP_DestroyDirectPlay2( This );
-  DP_DestroyIUnknown( This );
-
   HeapFree( GetProcessHeap(), 0, This );
 
   *ppvObj = NULL;
@@ -483,7 +456,8 @@ static ULONG WINAPI DP_Release( IDirectPlayImpl *This )
      /* If we're destroying the object, this must be the last ref
         of the last interface */
      DP_DestroyDirectPlay2( This );
-     DP_DestroyIUnknown( This );
+     This->lock.DebugInfo->Spare[0] = 0;
+     DeleteCriticalSection( &This->lock );
      HeapFree( GetProcessHeap(), 0, This );
   }
 
diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h
index e86c083..4684f53 100644
--- a/dlls/dplayx/dplay_global.h
+++ b/dlls/dplayx/dplay_global.h
@@ -31,11 +31,6 @@ extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
                                 LPCVOID lpAddress, DWORD dwAddressSize,
                                 LPVOID lpContext ) DECLSPEC_HIDDEN;
 
-typedef struct tagDirectPlayIUnknownData
-{
-  CRITICAL_SECTION  DP_lock;
-} DirectPlayIUnknownData;
-
 typedef struct tagEnumSessionAsyncCallbackData
 {
   LPSPINITDATA lpSpData;
@@ -190,7 +185,7 @@ typedef struct IDirectPlayImpl
   IDirectPlay4A IDirectPlay4A_iface;
   IDirectPlay4  IDirectPlay4_iface;
   LONG ulInterfaceRef;
-  DirectPlayIUnknownData *unk;
+  CRITICAL_SECTION lock;
   DirectPlay2Data *dp2;
 } IDirectPlayImpl;
 
diff --git a/dlls/dplayx/dplayx_messages.c b/dlls/dplayx/dplayx_messages.c
index bc888f6..7756c9f 100644
--- a/dlls/dplayx/dplayx_messages.c
+++ b/dlls/dplayx/dplayx_messages.c
@@ -171,9 +171,9 @@ HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This,
   lpReplyStructList->replyExpected.dwMsgBodySize  = 0;
 
   /* Insert into the message queue while locked */
-  EnterCriticalSection( &This->unk->DP_lock );
+  EnterCriticalSection( &This->lock );
     DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected );
-  LeaveCriticalSection( &This->unk->DP_lock );
+  LeaveCriticalSection( &This->lock );
 
   return lpReplyStructList->replyExpected.hReceipt;
 }
@@ -432,10 +432,10 @@ void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId,
   /* Find, and immediately remove (to avoid double triggering), the appropriate entry. Call locked to
    * avoid problems.
    */
-  EnterCriticalSection( &This->unk->DP_lock );
+  EnterCriticalSection( &This->lock );
     DPQ_REMOVE_ENTRY( This->dp2->repliesExpected, repliesExpected, replyExpected.wExpectedReply,
                      ==, wCommandId, lpReplyList );
-  LeaveCriticalSection( &This->unk->DP_lock );
+  LeaveCriticalSection( &This->lock );
 
   if( lpReplyList != NULL )
   {




More information about the wine-cvs mailing list