From afdf0efbd137f3e3d6509bba8b397be02baf1b9a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 18 Apr 2019 00:17:58 -0700 Subject: [PATCH] ircd::buffer: Tweak unique_buffer semantics. --- include/ircd/buffer/unique_buffer.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/ircd/buffer/unique_buffer.h b/include/ircd/buffer/unique_buffer.h index debc023d6..3d81b6960 100644 --- a/include/ircd/buffer/unique_buffer.h +++ b/include/ircd/buffer/unique_buffer.h @@ -28,8 +28,8 @@ struct ircd::buffer::unique_buffer unique_buffer() = default; unique_buffer(const size_t &size, const size_t &align = 0); - explicit unique_buffer(const buffer &); - explicit unique_buffer(unique_buffer &&) noexcept; + explicit unique_buffer(const const_buffer &); + unique_buffer(unique_buffer &&) noexcept; unique_buffer(const unique_buffer &) = delete; unique_buffer &operator=(unique_buffer &&) & noexcept; unique_buffer &operator=(const unique_buffer &) = delete; @@ -37,12 +37,14 @@ struct ircd::buffer::unique_buffer }; template -ircd::buffer::unique_buffer::unique_buffer(const buffer &src) -:unique_buffer +ircd::buffer::unique_buffer::unique_buffer(const const_buffer &src) +:buffer { - size(src) + allocator::aligned_alloc(0, ircd::buffer::size(src)).release(), ircd::buffer::size(src) } { + using ircd::buffer::size; + assert(this->begin() != nullptr); assert(size(src) == size(*this)); const mutable_buffer dst @@ -58,7 +60,7 @@ ircd::buffer::unique_buffer::unique_buffer(const size_t &size, const size_t &align) :buffer { - aligned_alloc(align, size).release(), size + allocator::aligned_alloc(align, size).release(), size } {} @@ -98,6 +100,7 @@ buffer ircd::buffer::unique_buffer::release() { const buffer ret{*this}; - this->begin() = nullptr; + std::get<0>(*this) = nullptr; + std::get<1>(*this) = nullptr; return ret; }