Skip to content

Commit

Permalink
Workaround a bug in MSVC when _CRTDBG_MAP_ALLOC is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Oct 18, 2015
1 parent caa8f76 commit 77b3200
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions format.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
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:
Expand All @@ -469,7 +469,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
public:
explicit MemoryBuffer(const Allocator &alloc = Allocator())
: Allocator(alloc), Buffer<T>(data_, SIZE) {}
~MemoryBuffer() { free(); }
~MemoryBuffer() { deallocate(); }

#if FMT_USE_RVALUE_REFERENCES
private:
Expand All @@ -486,7 +486,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
} 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_;
}
}
Expand All @@ -498,7 +498,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {

MemoryBuffer &operator=(MemoryBuffer &&other) {
assert(this != &other);
free();
deallocate();
move(other);
return *this;
}
Expand All @@ -524,7 +524,7 @@ void MemoryBuffer<T, SIZE, Allocator>::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.
Expand Down

0 comments on commit 77b3200

Please sign in to comment.