[asan/tsan] use InternalScopedBuffer instead of stack arrays. Use mmap inseted of InternalAlloc in InternalScopedBuffer
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162834 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h
index 76ab6e6..2879193 100644
--- a/lib/sanitizer_common/sanitizer_common.h
+++ b/lib/sanitizer_common/sanitizer_common.h
@@ -55,15 +55,17 @@
// InternalScopedBuffer can be used instead of large stack arrays to
// keep frame size low.
+// FIXME: use InternalAlloc instead of MmapOrDie once
+// InternalAlloc is made libc-free.
template<typename T>
class InternalScopedBuffer {
public:
explicit InternalScopedBuffer(uptr cnt) {
cnt_ = cnt;
- ptr_ = (T*)InternalAlloc(cnt * sizeof(T));
+ ptr_ = (T*)MmapOrDie(cnt * sizeof(T), "InternalScopedBuffer");
}
~InternalScopedBuffer() {
- InternalFree(ptr_);
+ UnmapOrDie(ptr_, cnt_ * sizeof(T));
}
operator T*() { return ptr_; }
T &operator[](uptr i) { return ptr_[i]; }