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.com>wrote:

>
> 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 is
> how to free bb, by delete aa, or by delete bb? Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to