mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Workaround a bug in MSVC when _CRTDBG_MAP_ALLOC is defined
This commit is contained in:
14
format.h
14
format.h
@ -458,9 +458,9 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
|
|||||||
private:
|
private:
|
||||||
T data_[SIZE];
|
T data_[SIZE];
|
||||||
|
|
||||||
// Free memory allocated by the buffer.
|
// Deallocate memory allocated by the buffer.
|
||||||
void free() {
|
void deallocate() {
|
||||||
if (this->ptr_ != data_) this->deallocate(this->ptr_, this->capacity_);
|
if (this->ptr_ != data_) Allocator::deallocate(this->ptr_, this->capacity_);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -469,7 +469,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
|
|||||||
public:
|
public:
|
||||||
explicit MemoryBuffer(const Allocator &alloc = Allocator())
|
explicit MemoryBuffer(const Allocator &alloc = Allocator())
|
||||||
: Allocator(alloc), Buffer<T>(data_, SIZE) {}
|
: Allocator(alloc), Buffer<T>(data_, SIZE) {}
|
||||||
~MemoryBuffer() { free(); }
|
~MemoryBuffer() { deallocate(); }
|
||||||
|
|
||||||
#if FMT_USE_RVALUE_REFERENCES
|
#if FMT_USE_RVALUE_REFERENCES
|
||||||
private:
|
private:
|
||||||
@ -486,7 +486,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
|
|||||||
} else {
|
} else {
|
||||||
this->ptr_ = other.ptr_;
|
this->ptr_ = other.ptr_;
|
||||||
// Set pointer to the inline array so that delete is not called
|
// Set pointer to the inline array so that delete is not called
|
||||||
// when freeing.
|
// when deallocating.
|
||||||
other.ptr_ = other.data_;
|
other.ptr_ = other.data_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,7 +498,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
|
|||||||
|
|
||||||
MemoryBuffer &operator=(MemoryBuffer &&other) {
|
MemoryBuffer &operator=(MemoryBuffer &&other) {
|
||||||
assert(this != &other);
|
assert(this != &other);
|
||||||
free();
|
deallocate();
|
||||||
move(other);
|
move(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -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
|
// the buffer already uses the new storage and will deallocate it in case
|
||||||
// of exception.
|
// of exception.
|
||||||
if (old_ptr != data_)
|
if (old_ptr != data_)
|
||||||
this->deallocate(old_ptr, old_capacity);
|
Allocator::deallocate(old_ptr, old_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A fixed-size buffer.
|
// A fixed-size buffer.
|
||||||
|
Reference in New Issue
Block a user