[Dune] [Dune-Commit] dune-localfunctions r869 - trunk/dune/localfunctions/utility

Christian Engwer christi at uni-hd.de
Fri Apr 23 20:32:38 CEST 2010


On Fri, Apr 23, 2010 at 08:21:36PM +0200, mnolte at dune-project.org wrote:
> Author: mnolte
> Date: 2010-04-23 20:21:36 +0200 (Fri, 23 Apr 2010)
> New Revision: 869
> 
> Modified:
>    trunk/dune/localfunctions/utility/coeffmatrix.hh
> Log:
> size+1 was on purpose (allocating only size entries will result in a segfault
> if the matrix is actually  dense)
> 
> 
> Modified: trunk/dune/localfunctions/utility/coeffmatrix.hh
> ===================================================================
> --- trunk/dune/localfunctions/utility/coeffmatrix.hh	2010-04-23 18:17:12 UTC (rev 868)
> +++ trunk/dune/localfunctions/utility/coeffmatrix.hh	2010-04-23 18:21:36 UTC (rev 869)
> @@ -164,7 +164,10 @@
>        delete [] skip_;
>  
>        Field* coeff = new Field[ size ];
> -      unsigned int *skip = new unsigned int[ size ];
> +      // we always initialize the next skip entry to zero,
> +      // including the one following the end, so allocate
> +      // size+1 entries so we will stay within the bounds.
> +      unsigned int *skip = new unsigned int[ size+1 ];
>        rows_ = new Field*[ numRows_+1 ];
>        std::vector<Field> row( numCols_ );
>  
> @@ -238,7 +241,7 @@
>        const unsigned int size = other.rows_[numRows_]-other.rows_[0];
>        coeff_ = new Field[ size ];
>        rows_ = new Field*[ numRows_+1 ];
> -      skip_ = new unsigned int[ size+1 ]; // size might do...
> +      skip_ = new unsigned int[ size ];
>        for (unsigned int i=0;i<size;++i)
>        {
>          coeff_[i] = other.coeff_[i];
> 
> 
> _______________________________________________
> Dune-Commit mailing list
> Dune-Commit at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-commit
> 




More information about the Dune mailing list