< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Memory leak when creating the SDP from string


Recently I found that my code has a leak when creating the SDP from string. I tried to find the correct way of doing this in examples/tests but could not understand who is responsible to delete the Data pointer. For instance, I found this:

/*

   WHAT PREVIOUSLY WORKED BUT NOW CORES...

   Data text(publishBody);

   HeaderFieldValue hfv(text.data(), text.size());

   Mime type("application", "pidf+xml");

   Pidf pc(&hfv, type);

   boost::shared_ptr<resip::Contents> body(&pc);

  

   ....

   WHAT NOW NEEDS TO BE DONE INSTEAD..

   */

   Data* text = new Data(publishBody);

   HeaderFieldValue hfv(text->data(), text->size());

   Mime type("application", "pidf+xml");

   Pidf* pc = new Pidf(hfv, type);

   boost::shared_ptr<resip::Pidf> body(pc);

   /*

   */

Is this the correct way? If so, who deletes the data in this code? I could not find in either HeaderFieldValue (in the constructor that takes a char * and size, mMine is set to false) nor in Contents (in my case SdpContents).
Another example, which is very similar to my case, is the generateBody in this example (I believe it is no longer in the current code base):
http://svn.resiprocate.org/dox/dum/testSMIMEInvite_8cxx_source.html#l00232
I did not test but I guess there is a leak in this example as well. Who deletes the pointer returned by generateBody and who deletes the Data * created inside the method?

I appreciate any help. Thanks in advance. Att,

Diego Domingos