Salome HOME
projects
/
modules
/
smesh.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
0022100: EDF 2413 SMESH: Take into account TRIA7
[modules/smesh.git]
/
src
/
SMDS
/
ObjectPool.hxx
diff --git
a/src/SMDS/ObjectPool.hxx
b/src/SMDS/ObjectPool.hxx
index 1ee3710556b2804591e9eb086455142911367455..abb7c15f2c1542080cb2fcbc60e2280efd3d92c9 100644
(file)
--- a/
src/SMDS/ObjectPool.hxx
+++ b/
src/SMDS/ObjectPool.hxx
@@
-1,4
+1,4
@@
-// Copyright (C) 2010-201
2
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2010-201
3
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
//
// 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 <vector>
#define _OBJECTPOOL_HXX_
#include <vector>
-#include <stack>
+
//
#include <stack>
#include <iostream>
#include <iostream>
+namespace
+{
+ // assure deallocation of memory of a vector
+ template<class Y> void clearVector(std::vector<Y>& v )
+ {
+ std::vector<Y> emptyVec; v.swap( emptyVec );
+ }
+}
+
template<class X> class ObjectPool
{
template<class X> class ObjectPool
{
@@
-70,7
+79,7
@@
public:
virtual ~ObjectPool()
{
virtual ~ObjectPool()
{
- for (
in
t i = 0; i < _chunkList.size(); i++)
+ for (
size_
t i = 0; i < _chunkList.size(); i++)
delete[] _chunkList[i];
}
delete[] _chunkList[i];
}
@@
-101,7
+110,7
@@
public:
void destroy(X* obj)
{
long adrobj = (long) (obj);
void destroy(X* obj)
{
long adrobj = (long) (obj);
- for (
in
t i = 0; i < _chunkList.size(); i++)
+ for (
size_
t i = 0; i < _chunkList.size(); i++)
{
X* chunk = _chunkList[i];
long adrmin = (long) (chunk);
{
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()
// void destroy(int toFree)
// {
// // no control 0<= toFree < _freeList.size()