mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
add method to clear the NodeList
This commit is contained in:
parent
4f0e472868
commit
12697c6b14
2 changed files with 17 additions and 0 deletions
|
@ -70,6 +70,8 @@ NodeList::NodeList(char newOwnerType, unsigned int newSocketListenPort) :
|
|||
NodeList::~NodeList() {
|
||||
delete _nodeTypesOfInterest;
|
||||
|
||||
clear();
|
||||
|
||||
// stop the spawned threads, if they were started
|
||||
stopSilentNodeRemovalThread();
|
||||
|
||||
|
@ -209,6 +211,19 @@ int NodeList::getNumAliveNodes() const {
|
|||
return numAliveNodes;
|
||||
}
|
||||
|
||||
void NodeList::clear() {
|
||||
// delete all of the nodes in the list, set the pointers back to NULL and the number of nodes to 0
|
||||
for (int i = 0; i < _numNodes; i++) {
|
||||
Node** nodeBucket = _nodeBuckets[i / NODES_PER_BUCKET];
|
||||
Node* node = nodeBucket[i % NODES_PER_BUCKET];
|
||||
|
||||
delete node;
|
||||
node = NULL;
|
||||
}
|
||||
|
||||
_numNodes = 0;
|
||||
}
|
||||
|
||||
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
||||
delete _nodeTypesOfInterest;
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
int size() { return _numNodes; }
|
||||
int getNumAliveNodes() const;
|
||||
|
||||
void clear();
|
||||
|
||||
void lock() { pthread_mutex_lock(&mutex); }
|
||||
void unlock() { pthread_mutex_unlock(&mutex); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue