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.

40 lines
561 B

  1. #include "precomp.h"
  2. CRefCount::CRefCount(DWORD dwStampID)
  3. :
  4. #ifndef SHIP_BUILD
  5. m_dwStampID(dwStampID),
  6. #endif
  7. m_cRefs(1)
  8. {
  9. }
  10. // though it is pure virtual, we still need to have a destructor.
  11. CRefCount::~CRefCount(void)
  12. {
  13. }
  14. LONG CRefCount::AddRef(void)
  15. {
  16. ASSERT(0 < m_cRefs);
  17. ::InterlockedIncrement(&m_cRefs);
  18. return m_cRefs;
  19. }
  20. LONG CRefCount::Release(void)
  21. {
  22. ASSERT(NULL != this);
  23. ASSERT(0 < m_cRefs);
  24. if (0 == ::InterlockedDecrement(&m_cRefs))
  25. {
  26. delete this;
  27. return 0;
  28. }
  29. return m_cRefs;
  30. }