Beispiel #1
0
        // Keep as void* and not byte* or other. Reduces typecasting from callers
        // who may have typed the pointer to their own needs.
        static public void Free(void *aPtr)
        {
            //TODO find a better way to remove the double look up here for GetPageType and then again in the
            // .Free methods which actually free the entries in the RAT.
            var xType = RAT.GetPageType(aPtr);

            switch (xType)
            {
            case RAT.PageType.HeapLarge:
                HeapLarge.Free(aPtr);
                break;

            default:
                throw new Exception("Heap item not found in RAT.");
            }
        }
Beispiel #2
0
        public unsafe void RATMethods()
        {
            var xRAM = new byte[1024 * 1024];

            fixed(byte *xPtr = xRAM)
            {
                RAT.Debug = true;

                RAT.Init(xPtr, (uint)xRAM.Length);

                var largePage = RAT.AllocPages(RAT.PageType.HeapLarge, 3);

                Assert.AreEqual(RAT.PageType.HeapLarge, RAT.GetPageType(largePage));
                Assert.AreEqual(RAT.GetFirstRATIndex(largePage), RAT.GetFirstRATIndex((byte *)largePage + 20));
                Assert.AreEqual(RAT.PageType.HeapLarge, RAT.GetPageType((byte *)largePage + RAT.PageSize));
            }
        }