From 056337b5f049af320b17cdfbed6cb4602679f425 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Mon, 2 Dec 2019 12:22:02 +0100 Subject: [PATCH] Disabled the move semantics from Buffer, just in case. Disabled the move semantics test --- src/sfizz/Buffer.h | 52 ++++++++++++++++++++++++---------------------- tests/BufferT.cpp | 10 ++++----- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/sfizz/Buffer.h b/src/sfizz/Buffer.h index 60b53e19..c790be3f 100644 --- a/src/sfizz/Buffer.h +++ b/src/sfizz/Buffer.h @@ -147,18 +147,19 @@ public: * * @param other */ - Buffer(Buffer&& other) - { - if (this != &other) { - std::free(paddedData); - largerSize = std::exchange(other.largerSize, 0); - alignedSize = std::exchange(other.alignedSize, 0); - paddedData = std::exchange(other.paddedData, nullptr); - normalData = std::exchange(other.normalData, nullptr); - normalEnd = std::exchange(other.normalEnd, nullptr); - _alignedEnd = std::exchange(other._alignedEnd, nullptr); - } - } + Buffer(Buffer&& other) = delete; + // { + // if (this != &other) { + // counter().bufferDeleted(largerSize * sizeof(value_type)); + // std::free(paddedData); + // largerSize = std::exchange(other.largerSize, 0); + // alignedSize = std::exchange(other.alignedSize, 0); + // paddedData = std::exchange(other.paddedData, nullptr); + // normalData = std::exchange(other.normalData, nullptr); + // normalEnd = std::exchange(other.normalEnd, nullptr); + // _alignedEnd = std::exchange(other._alignedEnd, nullptr); + // } + // } Buffer& operator=(const Buffer& other) { @@ -169,19 +170,20 @@ public: return *this; } - Buffer& operator=(Buffer&& other) - { - if (this != &other) { - std::free(paddedData); - largerSize = std::exchange(other.largerSize, 0); - alignedSize = std::exchange(other.alignedSize, 0); - paddedData = std::exchange(other.paddedData, nullptr); - normalData = std::exchange(other.normalData, nullptr); - normalEnd = std::exchange(other.normalEnd, nullptr); - _alignedEnd = std::exchange(other._alignedEnd, nullptr); - } - return *this; - } + Buffer& operator=(Buffer&& other) = delete; + // { + // if (this != &other) { + // counter().bufferDeleted(largerSize * sizeof(value_type)); + // std::free(paddedData); + // largerSize = std::exchange(other.largerSize, 0); + // alignedSize = std::exchange(other.alignedSize, 0); + // paddedData = std::exchange(other.paddedData, nullptr); + // normalData = std::exchange(other.normalData, nullptr); + // normalEnd = std::exchange(other.normalEnd, nullptr); + // _alignedEnd = std::exchange(other._alignedEnd, nullptr); + // } + // return *this; + // } Type& operator[](int idx) { return *(normalData + idx); } constexpr pointer data() const noexcept { return normalData; } diff --git a/tests/BufferT.cpp b/tests/BufferT.cpp index 9c79ae22..873d39b9 100644 --- a/tests/BufferT.cpp +++ b/tests/BufferT.cpp @@ -157,8 +157,8 @@ TEST_CASE("[Buffer] Copy and move") checkBoundaries(copyConstructed, baseSize); REQUIRE(std::all_of(copyConstructed.begin(), copyConstructed.end(), [](auto value) { return value == 1.0f; })); - sfz::Buffer moveConstructed { std::move(buffer) }; - REQUIRE(buffer.empty()); - checkBoundaries(moveConstructed, baseSize); - REQUIRE(std::all_of(moveConstructed.begin(), moveConstructed.end(), [](auto value) { return value == 1.0f; })); -} \ No newline at end of file + // sfz::Buffer moveConstructed { std::move(buffer) }; + // REQUIRE(buffer.empty()); + // checkBoundaries(moveConstructed, baseSize); + // REQUIRE(std::all_of(moveConstructed.begin(), moveConstructed.end(), [](auto value) { return value == 1.0f; })); +}