示例#1
0
        public IB Reserve(AllocationInfo allocationInfo)
        {
            amapRegionUpdater.Update(
                allocationInfo.MapOffset,
                map =>
            {
                var bits = map.Data.Value.ToBits();

                for (var i = allocationInfo.BitStartIndex; i <= allocationInfo.BitEndIndex; i++)
                {
                    bits[i] = 1;
                }

                var bytes = bits.ToBytes();

                return
                (new AMap(
                     BinaryData.OfValue(bytes),
                     new PageTrailer(
                         Constants.ptypeAMap,
                         Constants.ptypeAMap,
                         0x0000,
                         Crc32.ComputeCrc32(bytes),
                         BID.OfValue(allocationInfo.MapOffset))));
            });

            var allocateSize = (allocationInfo.BitEndIndex - allocationInfo.BitStartIndex + 1) * 64;

            headerUsageProvider.Use(header => header.SetRoot(header.Root.SetFreeSpaceInAllAMaps(header.Root.AMapFree - allocateSize)));

            return(IB.OfValue(allocationInfo.MapOffset + allocationInfo.BitStartIndex * 64));
        }
示例#2
0
        private FPMap CreateFPMap(long mapOffset)
        {
            var data = BinaryData.OfSize(496, 0xFF);

            return
                (new FPMap(
                     data,
                     new PageTrailer(
                         Constants.ptypeFPMap,
                         Constants.ptypeFPMap,
                         0x0000,
                         (int)Crc32.ComputeCrc32(data.Value),
                         BID.OfValue(mapOffset))));
        }
示例#3
0
        private AMap CreateAMap(long mapOffset, params byte[] defaultAllocations)
        {
            var data = new byte[496];

            for (var i = 0; i < defaultAllocations.Length; i++)
            {
                data[i] = defaultAllocations[i];
            }

            return
                (new AMap(
                     BinaryData.OfValue(data),
                     new PageTrailer(
                         Constants.ptypeAMap,
                         Constants.ptypeAMap,
                         0x0000,
                         (int)Crc32.ComputeCrc32(data),
                         BID.OfValue(mapOffset))));
        }