Пример #1
0
 /// <summary>
 /// Allocates and return the arrays for a total of <paramref name="size"/> <see cref="T"/> elements
 /// </summary>
 /// <param name="size">The total size of the arrays to return</param>
 /// <returns></returns>
 public BufferPtr[] Allocate(int size)
 {
     lock (_bufferManager)
     {
         return(_bufferManager.Allocate(size));
     }
 }
Пример #2
0
        public static AutoPtr[] AllocateAuto(this IUnmanagedBufferManager manager, int size)
        {
            var ptrs = manager.Allocate(size);
            var ret  = new AutoPtr[ptrs.Length];

            for (int i = 0; i < ptrs.Length; i++)
            {
                ret[i] = new AutoPtr(ptrs[i], ptr => manager.Free(ptr));
            }

            return(ret);
        }