Esempio n. 1
0
        /// <summary>
        /// Shrink space
        /// </summary>
        internal void ShrinkObject(VSObject o, long new_size)
        {
            if (o.Chunk == 1)
            {
                long         current_size = o.Size;
                VSAllocation a            = o.LastChunk;
                while ((current_size - a.Length) >= new_size)
                {
                    VSAllocation prev_alloc = a.PrevChunk;


                    if (prev_alloc.Chunk == 1)          // 1st segment
                    {
                        o.LAST  = 0;
                        o.Chunk = 0;
                    }
                    else
                    {
                        o.LAST           = prev_alloc.DescriptorAddress;
                        prev_alloc.Chunk = (short)(prev_alloc.Chunk * (-1));
                    }

                    current_size -= a.Length;
                    o.SetSize(current_size);
                    FreeSpaceSegment(a, false);
                    a = prev_alloc;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Release allocated space by object
        /// </summary>
        /// <param name="a"></param>
        /// <param name="deleteID"></param>
        public void Release(VSObject a, bool deleteID = true)
        {
            // Cannot be a system pool (0 or less)
            if (a.Pool < 1)
            {
                throw new VSException(DEFS.E0012_INVALID_POOL_NUMBER_CODE, "- " + a.Pool.ToString() + " (Release)");
            }

            Free(a, deleteID);
        }