I'm testing protocol buffers, but encountered segment fault that i can't
understand.
My protocol buffer is below
```
message Sub {
string value = 1;
}
message Wrapping {
int32 key = 1;
repeated Sub sub = 2;
}
```
Testing code is below
```
void Test()
{
gbtest::Sub* sub = new gbtest::Sub();
for(int i = 0 ; i<4 ; ++i)
{
gbtest::Wrapping wrapping; // Local variable
wrapping.mutable_sub()->AddAllocated(sub);
wrapping.set_key(i);
std::cout << "Size -> " << wrapping->mutable_sub()->size() << std::endl;
}
}
```
I want copy sub's pointer to each newed wrapping rather than copy it's data.
How can i achieve this?
Plz tell me how.
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.