[protobuf] whose responsibility to delete the PB message which is added by set_allocated_xxx(xxx* ptr)?

2013-07-23 Thread Icymaple Han
Hi, I am using protobuf in C++ but confused by set_allocated_xxx. For example, there is a message PB_a which has a member of message PB_b. First create a PB_a object named aa and a PB_b object named bb via new PB_a() and new PB_b(). Then add bb to aa via set_allocated_PB_b(). So the question

Re: [protobuf] whose responsibility to delete the PB message which is added by set_allocated_xxx(xxx* ptr)?

2013-07-23 Thread Feng Xiao
After aa-set_allocated_PB_b(bb) aa will take the ownership of bb. It means aa will be responsible to delete bb, so you only need to delete aa. On Tue, Jul 23, 2013 at 5:42 AM, Icymaple Han icymaple2...@gmail.comwrote: Hi, I am using protobuf in C++ but confused by set_allocated_xxx. For