FreeObject.h 1018 B

1234567891011121314151617181920212223242526272829303132
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace Memory
  7. {
  8. struct FreeObject
  9. {
  10. public:
  11. FreeObject * GetNext() const
  12. {
  13. AssertMsg((taggedNext & TaggedBit) == TaggedBit, "Free list corrupted");
  14. return (FreeObject *)(taggedNext & ~TaggedBit);
  15. }
  16. void SetNext(FreeObject * next)
  17. {
  18. Assert(((INT_PTR)next & TaggedBit) == 0);
  19. taggedNext = ((INT_PTR)next) | TaggedBit;
  20. }
  21. void ZeroNext() { taggedNext = 0; }
  22. #ifdef RECYCLER_MEMORY_VERIFY
  23. #pragma warning(suppress:4310)
  24. void DebugFillNext() { taggedNext = (INT_PTR)0xCACACACACACACACA; }
  25. #endif
  26. private:
  27. INT_PTR taggedNext;
  28. static INT_PTR const TaggedBit = 0x1;
  29. };
  30. }