diff --git a/dune/common/poolallocator.hh b/dune/common/poolallocator.hh index ff873c50706ebc4e84c52da0a319f8cf29316922..e58416f0aa2b0e27003fb7361d65ca553ca3a118 100644 --- a/dune/common/poolallocator.hh +++ b/dune/common/poolallocator.hh @@ -526,6 +526,18 @@ namespace Dune inline void Pool<T,S>::free(void* b) { if(b) { +#ifndef NDEBUG + Chunk* current=chunks_; + while(current) { + std::cout<<"b: "<<b<<" start: "<<¤t->chunk_<<" end:"<<(¤t->chunk_)+chunkSize<<std::endl; + if(static_cast<void*>(¤t->chunk_)<=b && + static_cast<void*>((¤t->chunk_)+chunkSize)>b) + break; + current=current->next_; + } + if(!current) + throw std::bad_alloc(); +#endif Reference* freed = static_cast<Reference*>(b); freed->next_ = head_; head_ = freed;