Avoid a refcount leak in QueryInterface when delegating.
[wine] / dlls / dplayx / dplayx_main.c
1 /* 
2  * DPLAYX.DLL LibMain
3  *
4  * Copyright 1999 - Peter Hunnisett 
5  *
6  * contact <hunnise@nortelnetworks.com>
7  */
8
9 #include "winbase.h"
10 #include "debugtools.h"
11 #include "dplayx_global.h"
12
13 DEFAULT_DEBUG_CHANNEL(dplay)
14
15 static DWORD DPLAYX_dwProcessesAttached = 0;
16
17 BOOL WINAPI DPLAYX_LibMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
18 {
19   switch ( fdwReason ) 
20   {
21     case DLL_PROCESS_ATTACH:
22     {
23
24       if ( DPLAYX_dwProcessesAttached == 0 )
25       {
26         /* First instance perform construction of global processor data */ 
27         DPLAYX_ConstructData();
28       } 
29
30       DPLAYX_dwProcessesAttached++;
31
32       break;
33     }
34
35     case DLL_PROCESS_DETACH:
36     {
37
38       DPLAYX_dwProcessesAttached--;
39      
40       if ( DPLAYX_dwProcessesAttached == 0 )
41       {
42         /* Last instance perform destruction of global processor data */
43         DPLAYX_DestructData(); 
44       }
45  
46       break;
47     }
48
49     case DLL_THREAD_ATTACH: /* Do nothing */
50     case DLL_THREAD_DETACH: /* Do nothing */
51       break;
52     default:                
53       break;
54
55   }
56
57   return TRUE;
58 }