Esempio n. 1
0
        public static DisposableValue <T[]> Resize(DisposableValue <T[]> source, int size)
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size", "Must be positive.");
            }

            var dest = AllocateDisposable(size);

            Array.Copy(source.Value, dest.Value, size < source.Value.Length ? size : source.Value.Length);
            source.Dispose();
            return(dest);
        }
Esempio n. 2
0
        public static DisposableValue <T[]> AllocateDisposable(int size)
        {
            var array = Allocate(size);

            return(DisposableValue <T[]> .Create(array, () => Free(array), size));
        }