Exemplo n.º 1
0
 public static byte[] AllocateByteArray(int size)
 {
     byte[] numArray;
     try
     {
         numArray = new byte[size];
     }
     catch (OutOfMemoryException outOfMemoryException1)
     {
         OutOfMemoryException outOfMemoryException = outOfMemoryException1;
         throw Fx.Exception.AsError(new InsufficientMemoryException(InternalSR.BufferAllocationFailed(size), outOfMemoryException));
     }
     return(numArray);
 }
Exemplo n.º 2
0
 public static char[] AllocateCharArray(int size)
 {
     try
     {
         // Safe to catch OOM from this as long as the ONLY thing it does is a simple allocation of a primitive type (no method calls).
         return(new char[size]);
     }
     catch (OutOfMemoryException exception)
     {
         // Convert OOM into an exception that can be safely handled by higher layers.
         throw Fx.Exception.AsError(
                   new InsufficientMemoryException(InternalSR.BufferAllocationFailed(size * sizeof(char)), exception));
     }
 }
Exemplo n.º 3
0
 public static char[] AllocateCharArray(int size)
 {
     char[] chrArray;
     try
     {
         chrArray = new char[size];
     }
     catch (OutOfMemoryException outOfMemoryException1)
     {
         OutOfMemoryException outOfMemoryException = outOfMemoryException1;
         throw Fx.Exception.AsError(new InsufficientMemoryException(InternalSR.BufferAllocationFailed(size * 2), outOfMemoryException));
     }
     return(chrArray);
 }