Skip to content
Snippets Groups Projects
Commit a1140b82 authored by Markus Blatt's avatar Markus Blatt
Browse files

[Merge] Fix FS#1041 and use Allocator::destroy instead of ~<type>()

Merged 1767 from trunk

[[Imported from SVN: r1771]]
parents 30989580 9c15ed1a
No related branches found
No related tags found
No related merge requests found
......@@ -548,9 +548,8 @@ namespace Dune {
// reallocate the rows if required
if (n>0 && n!=Mat.n) {
// free rows
int i=n;
while (i)
r[--i].~row_type();
for(row_type *riter=r+(n-1), *rend=r-1; riter!=rend; --riter)
rowAllocator_.destroy(riter);
rowAllocator_.deallocate(r,n);
}
......@@ -1346,8 +1345,8 @@ namespace Dune {
// a,j have been allocated as one long vector
j.reset();
int i=nnz;
while (i)
a[--i].~B();
for(B *aiter=a+(nnz-1), *aend=a-1; aiter!=aend; --aiter)
allocator_.destroy(aiter);
allocator_.deallocate(a,n);
}
else
......@@ -1357,9 +1356,9 @@ namespace Dune {
if (r[i].getsize()>0)
{
int j=r[i].getsize();
while (j) {
r[i].getindexptr()[--j].~size_type();
r[i].getptr()[j].~B();
for (B *col=r[i].getptr()+(r[i].getsize()-1),
*colend = r[i].getptr()-1; col!=colend; --col) {
allocator_.destroy(col);
}
sizeAllocator_.deallocate(r[i].getindexptr(),1);
allocator_.deallocate(r[i].getptr(),1);
......@@ -1369,8 +1368,8 @@ namespace Dune {
// deallocate the rows
if (n>0 && deallocateRows) {
int i=n;
while (i)
r[--i].~row_type();
for(row_type *riter=r+(n-1), *rend=r-1; riter!=rend; --riter)
rowAllocator_.destroy(riter);
rowAllocator_.deallocate(r,n);
}
......@@ -1437,7 +1436,10 @@ namespace Dune {
}else{
a = 0;
j.reset();
for(row_type* ri=r; ri!=r+rows; ++ri)
rowAllocator_.construct(ri, row_type());
}
// Mark the matrix as not built.
ready = notbuilt;
}
......
......@@ -79,11 +79,20 @@ struct Builder<Dune::BCRSMatrix<B,A> >
}
};
void testDoubleSetSize()
{
Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> > foo;
foo.setSize(5,5);
foo.setSize(5,5);
}
int main()
{
try{
Builder<Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> > > builder;
builder.randomBuild(5,4);
testDoubleSetSize();
}catch(Dune::Exception e) {
std::cerr << e<<std::endl;
return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment