Plugging leaks

This commit is contained in:
Paul Ferrand 2019-12-02 01:34:44 +01:00
parent 8f391b9654
commit 5d8e758724

View file

@ -149,6 +149,8 @@ public:
*/ */
Buffer(Buffer<Type>&& other) Buffer(Buffer<Type>&& other)
{ {
if (this != &other) {
std::free(paddedData);
largerSize = std::exchange(other.largerSize, 0); largerSize = std::exchange(other.largerSize, 0);
alignedSize = std::exchange(other.alignedSize, 0); alignedSize = std::exchange(other.alignedSize, 0);
paddedData = std::exchange(other.paddedData, nullptr); paddedData = std::exchange(other.paddedData, nullptr);
@ -156,6 +158,7 @@ public:
normalEnd = std::exchange(other.normalEnd, nullptr); normalEnd = std::exchange(other.normalEnd, nullptr);
_alignedEnd = std::exchange(other._alignedEnd, nullptr); _alignedEnd = std::exchange(other._alignedEnd, nullptr);
} }
}
Buffer<Type>& operator=(const Buffer<Type>& other) Buffer<Type>& operator=(const Buffer<Type>& other)
{ {
@ -188,6 +191,7 @@ public:
constexpr iterator end() noexcept { return normalEnd; } constexpr iterator end() noexcept { return normalEnd; }
constexpr pointer alignedEnd() noexcept { return _alignedEnd; } constexpr pointer alignedEnd() noexcept { return _alignedEnd; }
private: private:
static constexpr auto AlignmentMask { Alignment - 1 }; static constexpr auto AlignmentMask { Alignment - 1 };
static constexpr auto TypeAlignment { Alignment / sizeof(value_type) }; static constexpr auto TypeAlignment { Alignment / sizeof(value_type) };