Boost logo

Boost Users :

Subject: [Boost-users] polymorphic archive use and memory leak
From: sam p (sameersp21_at_[hidden])
Date: 2008-12-02 12:50:42


Hi,

    I am using polymorphic archive in my code and I am using it as follows,

1 void func(std::stringstream &ss, boost::archive::polymorphic_oarchive
*&ptr)
2 {
3 ptr = new boost::archive::polymorphic_text_oarchive(ss);
4 return;
5 }
6 int main()
7 {
8 std::stringstream ss;
9 boost::archive::polymorphic_oarchive *ptr = NULL;
10 func(ss, ptr);
11 delete ptr; //Will this delete object properly?????
12 }

Now the question is, whether 'delete' one line no. 11 will work properly or
not?
And is this a right way to use polymorphic archive?

Thanks,
Sameer



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net