currently i try to generate dynamic messages out of a .proto descriptor 
loaded at runtime and have some problems with the ownership of the created 
messages. A simple break-down of my code will look like this:

DynamicMessageFactory dynamicMessageFactory;
Arena arena;
const Descriptor* messageDesc = protoFileDescriptor->FindMessageTypeByName( 
"Foo" );
Message* message = dynamicMessageFactory.GetPrototype( messageDesc 

As i said, the protoFileDescriptor is a Descriptor of a .proto message 
which i load at runtime. Now i wan't to create messages from it, which are 
only known by name at runtime (in this example "Foo"). Also i wan't to use 
a Arena for all Message creations out of this .proto Descriptor.

Unfortunately this will not work, cause the Arena will try to release the 
message he use to own and the DynamicMessageFactory will also try to delete 
the created message. This means everything will work well till the 
DynamicMessageFactory or Arena (or both in this case) will get out of scope 
and try to delete there "owned" message instances.

The Message::New method description say's that the ownership for this 
message will be passed to the caller ... or in this case the given Arena.

Is there another way to generate Message instances out of a Descriptor 
instead of using the DynamicMessageFactory?
It is not intended to use the DynamicMessageFactory in common with a Arena?

With best regards,


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/d/optout.

Reply via email to