How can I free memory allocated when deserializing with boost::archive::text_iarchive

Thanks for your reply. Here is a code sample:
std::istringstream istr;
<* put data into istr here *>
boost::archive::text_iarchive ia(istr_);
Message* p_temp;
ia & p_temp;
mpBaseIncomingMessage = p_temp; // mpBaseIncomingMessage is of type (Message *)
mpIncomingMessage = static_cast
Dave Abrahams
writes: It has come to my attention that this book appears to use the work of others without attribution. I'd like to give the authors a chance to explain why that appearance is false. From what you can see in Amazon's limited preview of the book, one can find numerous instances of code lifted from Andrew Sutton's "origin" library. Some of the data structures have been renamed or had the case changed. Most of the duplication of Origin code comes in Chapter 7 in that book. There appear to be no references to Origin in that chapter (based on searching through the book in Amazon).
The IndirectlyCopyable text includes unsourced quotes directly from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3351.pdf without quotation, and the concepts* diagrams are taken from the same document. Is there an attribution on the previous page that we can't see from Amazon's limited preview?
Crediting the work of others have been done in the book as mentioned in the links below: Preface : http://www.algocoders.com/sites/default/files/preface_foa_revised.pdf Acknowledgement : http://www/algocoders.com/sites/default/files/acknowledgement_foa.pdf Table of Contents : http://www.algocoders.com/sites/default/files/toc_foa_revised.pdf
Chapter 3 : http://www.algocoders.com/sites/default/files/chapter3_foa.pdf Chapter 11 : http://www.algocoders.com/sites/default/files/chapter11_foa.pdf
We have avoided repetitive mention of original sources in respective chapters to let not the content be littered with these details again. Please let us know if we need to attribute in respective chapters too, we would like to work on it. Your feedback will be really helpful to guide us as a corrective measure.
Looking forward for suggestions,
Cheers, Algocoders
Only the last link for Chapter 11 actually works and there aren't any acknowledgements presented in that pdf.
--
Bill
------------------------------
Message: 2
Date: Mon, 4 Feb 2013 19:46:54 +0000
From: Adlai Shawareb

A general comment on using this mailing list is to reply directly to the message, and to put the library in question in square brackets such as [serialization]. On 2/4/2013 9:29 PM, Adlai Shawareb wrote:
Thanks for your reply. Here is a code sample:
std::istringstream istr; <* put data into istr here *> boost::archive::text_iarchive ia(istr_);
Message* p_temp; ia & p_temp; mpBaseIncomingMessage = p_temp; // mpBaseIncomingMessage is of type (Message *)
mpIncomingMessage = static_cast
(mpBaseIncomingMessage); // mpIncomingMessage is a pointer to a class derived from Message mObjectCallbackMap.process(mpIncomingMessage->mEvent); // execute a callback for this event delete mpIncomingMessage; // delete the allocated memory We then see a crash on either the " mObjectCallbackMap.process..." line or the " delete mpIncomingMessage", but only when certain actions are taken by the system.
Any thoughts would be greatly appreciated.
Serialization library is designed to work with symmetrically serialized/de-serialized data. How are you serializing the Message*? You can save yourself lots of time by using boost::polymorphic_downcast in situations like your usage of static_cast above to ensure you actually have a base pointer pointing to the derived type you think you have. Also creating a standalone minimal example demonstrating the problem usually helps you detect where things have gone awry. Jeff
participants (2)
-
Adlai Shawareb
-
Jeff Flinn