예제 #1
0
파일: Heaps.cs 프로젝트: sandkum/corefx
        // Trims the alignment padding of the heap.
        // See StgStringPool::InitOnMem in ndp\clr\src\Utilcode\StgPool.cpp.

        // This is especially important for EnC.
        private static MemoryBlock TrimEnd(MemoryBlock block)
        {
            if (block.Length == 0)
            {
                return(block);
            }

            int i = block.Length - 1;

            while (i >= 0 && block.PeekByte(i) == 0)
            {
                i--;
            }

            // this shouldn't happen in valid metadata:
            if (i == block.Length - 1)
            {
                return(block);
            }

            // +1 for terminating \0
            return(block.GetMemoryBlockAt(0, i + 2));
        }