X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FObjectPool.hxx;h=261ed6459b574aadcfba86b21aa84bc0a7647b21;hp=ae4ec75f98356d64b50b9c9183fe91e3a40f18a3;hb=20c126bc220757c06b5576f71ed6f34ae85e3e40;hpb=2c607013a23bd4e7ba07e72e0c04dee2c1209cff diff --git a/src/SMDS/ObjectPool.hxx b/src/SMDS/ObjectPool.hxx index ae4ec75f9..261ed6459 100644 --- a/src/SMDS/ObjectPool.hxx +++ b/src/SMDS/ObjectPool.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2010-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -21,9 +21,18 @@ #define _OBJECTPOOL_HXX_ #include -#include +//#include #include +namespace +{ + // assure deallocation of memory of a vector + template void clearVector(std::vector& v ) + { + std::vector emptyVec; v.swap( emptyVec ); + } +} + template class ObjectPool { @@ -70,7 +79,7 @@ public: virtual ~ObjectPool() { - for (int i = 0; i < _chunkList.size(); i++) + for (size_t i = 0; i < _chunkList.size(); i++) delete[] _chunkList[i]; } @@ -101,7 +110,7 @@ public: void destroy(X* obj) { long adrobj = (long) (obj); - for (int i = 0; i < _chunkList.size(); i++) + for (size_t i = 0; i < _chunkList.size(); i++) { X* chunk = _chunkList[i]; long adrmin = (long) (chunk); @@ -121,6 +130,16 @@ public: } } + void clear() + { + _nextFree = 0; + _maxAvail = 0; + for (size_t i = 0; i < _chunkList.size(); i++) + delete[] _chunkList[i]; + clearVector( _chunkList ); + clearVector( _freeList ); + } + // void destroy(int toFree) // { // // no control 0<= toFree < _freeList.size()