With the following proto file
message Foo {
// ...
}
message MyMessage {
Foo foo = 1;
}
I set foo
with the generated set_allocated_foo
method which takes ownership of the pointer:
MyMessage m;
m.set_allocated_foo(new Foo);
clang-tidy gives me the following warning though when m
leaves the scope:
warning: Potential memory leak [clang-analyzer-cplusplus.NewDeleteLeaks]
}
^
note: Memory is allocated
m.set_allocated_foo(new Foo);
^
Is there any way to avoid that? (without using // NOLINT
)