iobuffer.cpp 662 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "iobuffer.h"
  2. #include "pool.h"
  3. #include <stdio.h>
  4. CIOBuffer::CIOBuffer()
  5. {
  6. Length = (0);
  7. NextBuf = (nullptr);
  8. PrevBuf = (nullptr);
  9. }
  10. CIOBuffer::~CIOBuffer()
  11. {
  12. }
  13. CIOBuffer* CIOBuffer::Alloc(const char * file, int line)
  14. {
  15. // std::cout<<"alloc:"<<file<<","<<line<<std::endl;
  16. return Alloc_Pool<CIOBuffer>::GetInstance().Alloc();
  17. }
  18. void CIOBuffer::OnFree()
  19. {
  20. Alloc_Pool<CIOBuffer>::GetInstance().Free(this);
  21. }
  22. CRef::CRef() :m_lRef(1)
  23. {
  24. }
  25. void CRef::AddRef()
  26. {
  27. m_lRef++;
  28. }
  29. long CRef::Release(const char * file, int line)
  30. {
  31. // std::cout<<"free:"<<file<<","<<line<<std::endl;
  32. long result = --m_lRef;
  33. if (result == 0)
  34. OnFree();
  35. return result;
  36. }