leak_check.cc
Go to the documentation of this file.
00001 // Copyright 2017 The Abseil Authors.
00002 //
00003 // Licensed under the Apache License, Version 2.0 (the "License");
00004 // you may not use this file except in compliance with the License.
00005 // You may obtain a copy of the License at
00006 //
00007 //      https://www.apache.org/licenses/LICENSE-2.0
00008 //
00009 // Unless required by applicable law or agreed to in writing, software
00010 // distributed under the License is distributed on an "AS IS" BASIS,
00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012 // See the License for the specific language governing permissions and
00013 // limitations under the License.
00014 
00015 // Wrappers around lsan_interface functions.
00016 // When lsan is not linked in, these functions are not available,
00017 // therefore Abseil code which depends on these functions is conditioned on the
00018 // definition of LEAK_SANITIZER.
00019 #include "absl/debugging/leak_check.h"
00020 
00021 #ifndef LEAK_SANITIZER
00022 
00023 namespace absl {
00024 bool HaveLeakSanitizer() { return false; }
00025 void DoIgnoreLeak(const void*) { }
00026 void RegisterLivePointers(const void*, size_t) { }
00027 void UnRegisterLivePointers(const void*, size_t) { }
00028 LeakCheckDisabler::LeakCheckDisabler() { }
00029 LeakCheckDisabler::~LeakCheckDisabler() { }
00030 }  // namespace absl
00031 
00032 #else
00033 
00034 #include <sanitizer/lsan_interface.h>
00035 
00036 namespace absl {
00037 bool HaveLeakSanitizer() { return true; }
00038 void DoIgnoreLeak(const void* ptr) { __lsan_ignore_object(ptr); }
00039 void RegisterLivePointers(const void* ptr, size_t size) {
00040   __lsan_register_root_region(ptr, size);
00041 }
00042 void UnRegisterLivePointers(const void* ptr, size_t size) {
00043   __lsan_unregister_root_region(ptr, size);
00044 }
00045 LeakCheckDisabler::LeakCheckDisabler() { __lsan_disable(); }
00046 LeakCheckDisabler::~LeakCheckDisabler() { __lsan_enable(); }
00047 }  // namespace absl
00048 
00049 #endif  // LEAK_SANITIZER


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:42:15