Exemple #1
0
        public static IntPtr AllocateClearedMemory(int sizeInBytes, byte clearValue = (byte)0, int align = 16)
        {
            IntPtr dest = Utilities.AllocateMemory(sizeInBytes, align);

            Utilities.ClearMemory(dest, clearValue, sizeInBytes);
            return(dest);
        }
Exemple #2
0
 public unsafe DataStream(int sizeInBytes, bool canRead, bool canWrite)
 {
     this._buffer     = (sbyte *)(void *)Utilities.AllocateMemory(sizeInBytes, 16);
     this._size       = (long)sizeInBytes;
     this._ownsBuffer = true;
     this._canRead    = canRead;
     this._canWrite   = canWrite;
 }
Exemple #3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "SharpDX.DataBuffer" /> class, and allocates a new buffer to use as a backing store.
        /// </summary>
        /// <param name = "sizeInBytes">The size of the buffer to be allocated, in bytes.</param>
        /// <exception cref = "T:System.ArgumentOutOfRangeException">
        ///   <paramref name = "sizeInBytes" /> is less than 1.</exception>
        public DataBuffer(int sizeInBytes)
        {
            unsafe
            {
                System.Diagnostics.Debug.Assert(sizeInBytes > 0);

                _buffer     = (sbyte *)Utilities.AllocateMemory(sizeInBytes);
                _size       = sizeInBytes;
                _ownsBuffer = true;
            }
        }
Exemple #4
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "SharpDX.DataStream" /> class, and allocates a new buffer to use as a backing store.
        /// </summary>
        /// <param name = "sizeInBytes">The size of the buffer to be allocated, in bytes.</param>
        /// <param name = "canRead">
        ///   <c>true</c> if reading from the buffer should be allowed; otherwise, <c>false</c>.</param>
        /// <param name = "canWrite">
        ///   <c>true</c> if writing to the buffer should be allowed; otherwise, <c>false</c>.</param>
        public DataStream(int sizeInBytes, bool canRead, bool canWrite)
        {
            unsafe
            {
                System.Diagnostics.Debug.Assert(sizeInBytes > 0);

                _buffer     = (sbyte *)Utilities.AllocateMemory(sizeInBytes);
                _size       = sizeInBytes;
                _ownsBuffer = true;
                _canRead    = canRead;
                _canWrite   = canWrite;
            }
        }
Exemple #5
0
 internal unsafe DataBuffer(void *buffer, int sizeInBytes, bool makeCopy)
 {
     if (makeCopy)
     {
         this._buffer = (sbyte *)(void *)Utilities.AllocateMemory(sizeInBytes, 16);
         Utilities.CopyMemory((IntPtr)((void *)this._buffer), (IntPtr)buffer, sizeInBytes);
     }
     else
     {
         this._buffer = (sbyte *)buffer;
     }
     this._size       = sizeInBytes;
     this._ownsBuffer = makeCopy;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComArray"/> class.
 /// </summary>
 /// <param name="array">The array.</param>
 public ComArray(params ComObject[] array)
 {
     values       = array;
     nativeBuffer = IntPtr.Zero;
     if (values != null)
     {
         int length = array.Length;
         values       = new ComObject[length];
         nativeBuffer = Utilities.AllocateMemory(length * Utilities.SizeOf <IntPtr>());
         for (int i = 0; i < length; i++)
         {
             Set(i, array[i]);
         }
     }
 }
Exemple #7
0
        internal unsafe DataBuffer(void *buffer, int sizeInBytes, bool makeCopy)
        {
            System.Diagnostics.Debug.Assert(sizeInBytes > 0);

            if (makeCopy)
            {
                _buffer = (sbyte *)Utilities.AllocateMemory(sizeInBytes);
                Utilities.CopyMemory((IntPtr)_buffer, (IntPtr)buffer, sizeInBytes);
            }
            else
            {
                _buffer = (sbyte *)buffer;
            }
            _size       = sizeInBytes;
            _ownsBuffer = makeCopy;
        }
Exemple #8
0
 internal unsafe DataStream(void *buffer, int sizeInBytes, bool canRead, bool canWrite, bool makeCopy)
 {
     if (makeCopy)
     {
         this._buffer = (sbyte *)(void *)Utilities.AllocateMemory(sizeInBytes, 16);
         Utilities.CopyMemory((IntPtr)((void *)this._buffer), (IntPtr)buffer, sizeInBytes);
     }
     else
     {
         this._buffer = (sbyte *)buffer;
     }
     this._size       = (long)sizeInBytes;
     this._canRead    = canRead;
     this._canWrite   = canWrite;
     this._ownsBuffer = makeCopy;
 }
Exemple #9
0
        public ComArray(params ComObject[] array)
        {
            this.values       = array;
            this.nativeBuffer = IntPtr.Zero;
            if (this.values == null)
            {
                return;
            }
            int length = array.Length;

            this.values       = new ComObject[length];
            this.nativeBuffer = Utilities.AllocateMemory(length * Utilities.SizeOf <IntPtr>(), 16);
            for (int index = 0; index < length; ++index)
            {
                this.Set(index, array[index]);
            }
        }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComArray"/> class.
 /// </summary>
 /// <param name="size">The size.</param>
 public ComArray(int size)
 {
     values       = new ComObject[size];
     nativeBuffer = Utilities.AllocateMemory(size * Utilities.SizeOf <IntPtr>());
 }
Exemple #11
0
 public unsafe DataBuffer(int sizeInBytes)
 {
     this._buffer     = (sbyte *)(void *)Utilities.AllocateMemory(sizeInBytes, 16);
     this._size       = sizeInBytes;
     this._ownsBuffer = true;
 }