Reputation: 125
When I using Protocol Buffer with Arena, what is the difference between those 2 functions
google::protobuf::Arena::CreateMaybeMessage<LPD::MyObj>();
And
google::protobuf::Arena::CreateMessage<LPD::MyObj>();
Upvotes: 3
Views: 690
Reputation: 1
This is pretty late, but the answer to your question is in the documentation, here. The Message's static "New()" function calls the CreateMaybeMessage function with a null Arena.
Message* New(Arena* arena): An alternate override for the standard New() method. It allows a new message object of this type to be created on the given arena. Its semantics are identical to Arena::CreateMessage(arena) if the concrete message type on which it is called is generated with arena allocation enabled. If the message type is not generated with arena allocation enabled, then it is equivalent to an ordinary allocation followed by arena->Own(message) if arena is not NULL.
Upvotes: 0