Commit 5aaa9dcf authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed bug in Array methods

The methods did not work with zero array size, so extra checks were
added.
parent 73b8074f
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ setSize( const Index size )
   Algorithms::ArrayOperations< Device >::allocateMemory( this->allocationPointer, size );
   this->data = this->allocationPointer;
   this->size = size;
   if( ! this->allocationPointer )
   if( size > 0 && ! this->allocationPointer )
   {
      std::cerr << "I am not able to allocate new array with size "
                << ( double ) this->size * sizeof( ElementType ) / 1.0e9 << " GB." << std::endl;
@@ -370,6 +370,7 @@ operator = ( const Array< Element, Device, Index >& array )
   TNL_ASSERT( array. getSize() == this->getSize(),
              std::cerr << "Source size: " << array. getSize() << std::endl
                        << "Target size: " << this->getSize() << std::endl );
   if( this->getSize() > 0 )
      Algorithms::ArrayOperations< Device >::
         template copyMemory< Element,
                              Element,
@@ -391,6 +392,7 @@ operator = ( const ArrayT& array )
   TNL_ASSERT( array. getSize() == this->getSize(),
              std::cerr << "Source size: " << array. getSize() << std::endl
                        << "Target size: " << this->getSize() << std::endl );
   if( this->getSize() > 0 )
      Algorithms::ArrayOperations< Device, typename ArrayT::DeviceType >::
         template copyMemory< Element,
                              typename ArrayT::ElementType,