Silence static analyzer warnings about memory leaks
The static analyzer complains that this memory is leaked regardless of how I try to work around it (unless we escape the memory by using a global or something, but...). Basically, as long as there's some sort of operation on the reinterpret_cast'ed pointer, it complains. If we remove the bitwise negations, it doesn't. Doing so would presumably defeat the purpose of this test, though, so add a NOLINT. Bug: 27101951 Test: mma. No more static analyzer warning for this file. Change-Id: If9008946a2145d17b8651535141bfd7ec9224739
This commit is contained in:
parent
7229576bfe
commit
80136a1e41
1 changed files with 3 additions and 0 deletions
|
@ -27,6 +27,9 @@ namespace android {
|
|||
|
||||
class HiddenPointer {
|
||||
public:
|
||||
// Since we're doing such a good job of hiding it, the static analyzer
|
||||
// thinks that we're leaking this `malloc`. This is probably related to
|
||||
// https://bugs.llvm.org/show_bug.cgi?id=34198. NOLINTNEXTLINE
|
||||
explicit HiddenPointer(size_t size = 256) { Set(malloc(size)); }
|
||||
~HiddenPointer() { Free(); }
|
||||
void* Get() { return reinterpret_cast<void*>(~ptr_); }
|
||||
|
|
Loading…
Reference in a new issue