Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.9 KiB

  1. #include "pch.hxx"
  2. #include "unknlist.h"
  3. #include <BadStrFunctions.h>
  4. // ******************************************************
  5. CUnknownList::~CUnknownList()
  6. {
  7. if (m_pList)
  8. m_pList->Release();
  9. }
  10. // ******************************************************
  11. ULONG CUnknownList::AddRef(void)
  12. {
  13. m_cRefCount++;
  14. return S_OK;
  15. }
  16. // ******************************************************
  17. ULONG CUnknownList::Release(void)
  18. {
  19. m_cRefCount--;
  20. if (0 == m_cRefCount)
  21. delete this;
  22. return S_OK;
  23. }
  24. // ******************************************************
  25. HRESULT CUnknownList::AddItem(IUnknown *pIUnk, DWORD *pdwHandle)
  26. {
  27. HRESULT hr = m_pList->AddItem(LPVOID(pIUnk), pdwHandle);
  28. if (SUCCEEDED(hr))
  29. pIUnk->AddRef();
  30. return hr;
  31. }
  32. // ******************************************************
  33. HRESULT CUnknownList::GetNext(LISTDIRECTION bDirection, IUnknown **ppIUnk, DWORD *pdwHandle)
  34. {
  35. HRESULT hr = m_pList->GetNext(bDirection, reinterpret_cast<void**>(ppIUnk), pdwHandle);
  36. if (SUCCEEDED(hr))
  37. (*ppIUnk)->AddRef();
  38. return hr;
  39. }
  40. // ======================================================
  41. // Static functions
  42. // ======================================================
  43. HRESULT CUnknownList::CreateInstance(CUnknownList** ppList)
  44. {
  45. HRESULT hr = S_OK;
  46. // Create me
  47. CUnknownList *pNew = new CUnknownList;
  48. if (NULL == pNew)
  49. hr = E_OUTOFMEMORY;
  50. hr = IVoidPtrList_CreateInstance(&(pNew->m_pList));
  51. if (NULL == pNew->m_pList)
  52. {
  53. delete pNew;
  54. pNew = NULL;
  55. }
  56. *ppList = pNew;
  57. // Done
  58. return hr;
  59. }
  60. HRESULT IUnknownList_CreateInstance(IUnknownList** ppList)
  61. {
  62. CUnknownList* pList;
  63. HRESULT hr = CUnknownList::CreateInstance(&pList);
  64. if (SUCCEEDED(hr))
  65. *ppList = static_cast<IUnknownList*>(pList);
  66. else
  67. *ppList = NULL;
  68. return hr;
  69. }