Y
Yi
There is originally a class called "message". For some reason, I need
to add "set<A> _update_list;" as a new
private data member of "message" ("A" can be IPv4 or IPv6, which are
defined elsewhere). In message.hh, I defined the following three
methods:
public:
void add_update(const A& this_ip) {
_update_list.insert(this_ip);
}
const set<A>& update_list() const {
return _update_list;
}
void copy_update_list(const set<A>& list) const {
_update_list = list;
}
private:
mutable set<A> _update_list;
Instead of changing the constructor, I added a statement explicitly
copying _update_list to a new object (using copy_update_list() )
everywhere a new message object is created by copying an existing
object.
add_update() is used to add IP addresses to the _update_list.
My questions is, if the message class has an empty destructor, would
the modification I did to the message class cause memory leak? (Would
_update_list be freed automatically?)
Thanks.
to add "set<A> _update_list;" as a new
private data member of "message" ("A" can be IPv4 or IPv6, which are
defined elsewhere). In message.hh, I defined the following three
methods:
public:
void add_update(const A& this_ip) {
_update_list.insert(this_ip);
}
const set<A>& update_list() const {
return _update_list;
}
void copy_update_list(const set<A>& list) const {
_update_list = list;
}
private:
mutable set<A> _update_list;
Instead of changing the constructor, I added a statement explicitly
copying _update_list to a new object (using copy_update_list() )
everywhere a new message object is created by copying an existing
object.
add_update() is used to add IP addresses to the _update_list.
My questions is, if the message class has an empty destructor, would
the modification I did to the message class cause memory leak? (Would
_update_list be freed automatically?)
Thanks.