I am new to using google protobuffers and I created a basic message:
message msg {
uint32 id = 1;
google.protobuf.Timestamp timestamp = 2;
}
Now I created a small c++ program to use this [with the necessary headers]
int main(void) {
auto m = msg{};
m.set_id(2);
auto timestamp = google::protobuf::Timestamp{};
timestamp.set_seconds(time(NULL));
timestamp.set_nanos(0);
m.set_allocated_timestamp(×tamp);
std::cout << m.id() << std::endl;
std::cout << m.timestamp().seconds() << std::endl;
return 0;
}
However, this program gives a seg fault.
free(): invalid pointer
[1] 9537 abort (core dumped)
where do I need to release memory?