|
Boost : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-04-17 14:35:57
AMDG
Phil Bouchard wrote:
> I have discovered also another bug related to the set counter. Now Vault
> contains the corrected version.
>
>
Ok. Another issue.
Is it possible to deal with this:
The nodes will never be cleaned up until the list is destroyed.
Or that's what I thought.... The nodes don't seem to be cleaned up at all.
#include <boost/shifted_ptr.hpp>
#include <vector>
#include <iostream>
static int count;
using boost::shifted_ptr;
using boost::new_sh;
struct node {
node() {
++count;
}
~node() {
--count;
}
node(const node&) {
++count;
}
shifted_ptr<node> prior;
shifted_ptr<node> next;
};
struct list {
public:
list() {}
void clear() {
front.reset();
back.reset();
}
void insert() {
if(front.get() == 0) {
front = back = new_sh<node>();
} else {
back->next = new_sh<node>();
back->next->prior = back;
back = back->next;
}
}
private:
shifted_ptr<node> front;
shifted_ptr<node> back;
};
int main() {
list l;
for(int j = 0; j < 10; ++j) {
for(int i = 0; i < 100; ++i) {
l.insert();
}
l.clear();
}
std::cout << count << std::endl;
}
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk