From 77b32006a3cdfb6d4a8154cb1a92f23602660207 Mon Sep 17 00:00:00 2001 From: vitaut Date: Sun, 18 Oct 2015 06:42:24 -0700 Subject: [PATCH] Workaround a bug in MSVC when _CRTDBG_MAP_ALLOC is defined --- format.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/format.h b/format.h index d25eab34..e1340e7c 100644 --- a/format.h +++ b/format.h @@ -458,9 +458,9 @@ class MemoryBuffer : private Allocator, public Buffer { private: T data_[SIZE]; - // Free memory allocated by the buffer. - void free() { - if (this->ptr_ != data_) this->deallocate(this->ptr_, this->capacity_); + // Deallocate memory allocated by the buffer. + void deallocate() { + if (this->ptr_ != data_) Allocator::deallocate(this->ptr_, this->capacity_); } protected: @@ -469,7 +469,7 @@ class MemoryBuffer : private Allocator, public Buffer { public: explicit MemoryBuffer(const Allocator &alloc = Allocator()) : Allocator(alloc), Buffer(data_, SIZE) {} - ~MemoryBuffer() { free(); } + ~MemoryBuffer() { deallocate(); } #if FMT_USE_RVALUE_REFERENCES private: @@ -486,7 +486,7 @@ class MemoryBuffer : private Allocator, public Buffer { } else { this->ptr_ = other.ptr_; // Set pointer to the inline array so that delete is not called - // when freeing. + // when deallocating. other.ptr_ = other.data_; } } @@ -498,7 +498,7 @@ class MemoryBuffer : private Allocator, public Buffer { MemoryBuffer &operator=(MemoryBuffer &&other) { assert(this != &other); - free(); + deallocate(); move(other); return *this; } @@ -524,7 +524,7 @@ void MemoryBuffer::grow(std::size_t size) { // the buffer already uses the new storage and will deallocate it in case // of exception. if (old_ptr != data_) - this->deallocate(old_ptr, old_capacity); + Allocator::deallocate(old_ptr, old_capacity); } // A fixed-size buffer.