Circumvent ASAN false positive

Summary:
Changes:
* checks if ASAN mode is on, and uses malloc and free in the constructor and destructor
Closes https://github.com/facebook/rocksdb/pull/2767

Differential Revision: D5671243

Pulled By: armishra

fbshipit-source-id: 8e4ad0f7f163400c4effa8617d3b30134119d802
main
Archit Mishra 7 years ago committed by Facebook Github Bot
parent 5b68b114f1
commit 09ac6206ab
  1. 16
      cache/lru_cache.cc

16
cache/lru_cache.cc vendored

@ -234,19 +234,35 @@ void LRUCacheShard::EvictFromLRU(size_t charge,
}
void* LRUCacheShard::operator new(size_t size) {
#if __SANITIZE_ADDRESS__
return malloc(size);
#else
return port::cacheline_aligned_alloc(size);
#endif
}
void* LRUCacheShard::operator new[](size_t size) {
#if __SANITIZE_ADDRESS__
return malloc(size);
#else
return port::cacheline_aligned_alloc(size);
#endif
}
void LRUCacheShard::operator delete(void *memblock) {
#if __SANITIZE_ADDRESS__
free(memblock);
#else
port::cacheline_aligned_free(memblock);
#endif
}
void LRUCacheShard::operator delete[](void* memblock) {
#if __SANITIZE_ADDRESS__
free(memblock);
#else
port::cacheline_aligned_free(memblock);
#endif
}
void LRUCacheShard::SetCapacity(size_t capacity) {

Loading…
Cancel
Save