[DELAYIMP] Fix 2 Clang-Cl warnings about __pfnDliNotifyHook2Default and __pfnDliFailu...
[reactos.git] / sdk / lib / drivers / sound / stdunk / cunknown.cpp
1 /*
2 ReactOS Kernel-Mode COM
3 IUnknown implementations
4
5 LICENSE
6 Please see COPYING in the top-level directory for license information.
7
8 AUTHORS
9 Andrew Greenwood
10 */
11
12 #include <stdunk.h>
13
14 CUnknown::CUnknown(PUNKNOWN outer_unknown)
15 {
16 m_ref_count = 0;
17
18 if ( outer_unknown )
19 m_outer_unknown = outer_unknown;
20 else
21 m_outer_unknown = PUNKNOWN(dynamic_cast<PNONDELEGATINGUNKNOWN>(this));
22 }
23
24 CUnknown::~CUnknown()
25 {
26 }
27
28 STDMETHODIMP_(ULONG)
29 CUnknown::NonDelegatingAddRef()
30 {
31 InterlockedIncrement(&m_ref_count);
32 return m_ref_count;
33 }
34
35 STDMETHODIMP_(ULONG)
36 CUnknown::NonDelegatingRelease()
37 {
38 if ( InterlockedDecrement(&m_ref_count) == 0 )
39 {
40 m_ref_count ++;
41 delete this;
42 return 0;
43 }
44
45 return m_ref_count;
46 }
47
48 STDMETHODIMP_(NTSTATUS)
49 CUnknown::NonDelegatingQueryInterface(
50 IN REFIID iid,
51 PVOID* ppVoid)
52 {
53 /* FIXME */
54 #if 0
55 if ( IsEqualGUID(iid, IID_IUnknown) ) /* TODO: Aligned? */
56 *ppVoid = PVOID(PUNKNOWN(this));
57 else
58 *ppVoid = NULL;
59 #endif
60
61 if ( *ppVoid )
62 {
63 PUNKNOWN(*ppVoid)->AddRef();
64 return STATUS_SUCCESS;
65 }
66
67 return STATUS_INVALID_PARAMETER;
68 }
69
70 #if __GNUC__
71 extern "C" void __cxa_pure_virtual() { ASSERT(FALSE); }
72 #endif