I am using Google Protocol Buffers in the following way:
void myfunc() {
Buffers::MyBuffer buf;
buf.ParseFromArray(data, datalen);
...
return;
}
The documentation for Protocol Buffers says that to free memory for a buffer that the object should be deleted. I’m no C++ genius, but I thought delete should only be called for objects allocated with new. Is memory cleaned up on return here?
Memory for a buffer should be deallocated as the object is destroyed.
release_foo
To keep buffer from deletion, use static New method:
If you need to keep any
SomeInternalBufferbut notMyBufferuserelease_<field>method: