Source code of Windows XP (NT5)
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.

59 lines
1.3 KiB

  1. //******************************************************************************
  2. //
  3. // NEWOBJ.CPP
  4. //
  5. // Copyright (C) 1996-1999 Microsoft Corporation
  6. //
  7. //******************************************************************************
  8. #include "precomp.h"
  9. #include <stdio.h>
  10. #include "newobj.h"
  11. _IWmiObject* CInstanceManager::Clone(_IWmiObject* pOld)
  12. {
  13. CInCritSec ics(&m_cs);
  14. _IWmiObject* p = (_IWmiObject*)m_Available.Unqueue();
  15. if(p)
  16. {
  17. p->AddRef();
  18. pOld->CloneEx(0, p);
  19. return p;
  20. }
  21. else
  22. {
  23. IWbemClassObject* pNew;
  24. HRESULT hres = pOld->Clone(&pNew);
  25. if(FAILED(hres))
  26. return NULL;
  27. _IWmiObject* pNewEx;
  28. pNew->QueryInterface(IID__IWmiObject, (void**)&pNewEx);
  29. pNew->Release();
  30. //pNewEx->SetDelete((void*)&CInstanceManager::Delete, this);
  31. return pNewEx;
  32. }
  33. }
  34. // static
  35. void CInstanceManager::Delete(void* pArg, _IWmiObject* p)
  36. {
  37. CInstanceManager* pThis = (CInstanceManager*)pArg;
  38. CInCritSec ics(&pThis->m_cs);
  39. pThis->m_Available.Enqueue(p);
  40. }
  41. void CInstanceManager::Clear()
  42. {
  43. CInCritSec ics(&m_cs);
  44. _IWmiObject* p = NULL;
  45. while(p = (_IWmiObject*)m_Available.Unqueue())
  46. {
  47. p->AddRef();
  48. //p->SetDelete(NULL, NULL);
  49. p->Release();
  50. }
  51. }