Esempio n. 1
0
        public void AddBlock(string Info, long VA, HashRec[] hashes, byte[] data = null)
        {
            // first time
            if (Regions.Count == 0)
            {
                var r = new SparseRegion()
                {
                    OriginationInfo = Info
                };
                if (data != null)
                {
                    r.Data.Add(data);
                }

                r.InnerList.Add(hashes);
                r.SparseAddrs.Add(VA);
                r.Address = VA;
                r.Len     = PAGE_SIZE;
                Regions.Add(r);
                return;
            }

            foreach (var r in Regions)
            {
                // merge
                if (Info == r.OriginationInfo)
                {
                    r.Len += PAGE_SIZE;
                    r.SparseAddrs.Add(VA);
                    r.InnerList.Add(hashes);
                    r.Data.Add(data);
                    return;
                }
            }

            var rx = new SparseRegion()
            {
                OriginationInfo = Info, Address = VA
            };

            if (data != null)
            {
                rx.Data.Add(data);
            }

            rx.InnerList.Add(hashes);
            rx.SparseAddrs.Add(VA);
            rx.Len += PAGE_SIZE;
            Regions.Add(rx);
        }
Esempio n. 2
0
        public void AddBlock(string Info, long VA, HashRec[] hashes, int validated)
        {
            if (Regions.Count == 0)
            {
                var r = new SparseRegion()
                {
                    OriginationInfo = Info
                };
                r.SparseAddrs.Add(VA);
                r.InnerList.Add(hashes);
                r.Address   = VA;
                r.Len       = PAGE_SIZE;
                r.Validated = validated;
                r.Total     = hashes.Length;
                Regions.Add(r);
                return;
            }

            foreach (var r in Regions)
            {
                // merge
                if (Info == r.OriginationInfo)
                {
                    r.Validated += validated;
                    r.Total     += hashes.Length;
                    r.Len       += PAGE_SIZE;
                    r.SparseAddrs.Add(VA);
                    r.InnerList.Add(hashes);
                    return;
                }
            }

            var rx = new SparseRegion()
            {
                OriginationInfo = Info, Address = VA
            };

            rx.SparseAddrs.Add(VA);
            rx.InnerList.Add(hashes);
            rx.Len       += PAGE_SIZE;
            rx.Validated += validated;
            rx.Total     += hashes.Length;

            Regions.Add(rx);
        }