aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/byte_slice.h
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-05-01 15:13:58 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-05-01 15:13:58 -0500
commit3e21e591b8201fdb852822b1d30faa1fb97d870a (patch)
tree66f7e7af1eb010d5ed97320916b40abc58a36268 /contrib/epee/include/byte_slice.h
parentMerge pull request #6487 (diff)
parentUse byte_slice for sending zmq messages - removes data copy within zmq (diff)
downloadmonero-3e21e591b8201fdb852822b1d30faa1fb97d870a.tar.xz
Merge pull request #6350
da99157 Use byte_slice for sending zmq messages - removes data copy within zmq (vtnerd)
Diffstat (limited to 'contrib/epee/include/byte_slice.h')
-rw-r--r--contrib/epee/include/byte_slice.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/epee/include/byte_slice.h b/contrib/epee/include/byte_slice.h
index 1fbba101e..bd9452b11 100644
--- a/contrib/epee/include/byte_slice.h
+++ b/contrib/epee/include/byte_slice.h
@@ -42,7 +42,12 @@ namespace epee
struct release_byte_slice
{
- void operator()(byte_slice_data*) const noexcept;
+ //! For use with `zmq_message_init_data`, use second arg for buffer pointer.
+ static void call(void*, void* ptr) noexcept;
+ void operator()(byte_slice_data* ptr) const noexcept
+ {
+ call(nullptr, ptr);
+ }
};
/*! Inspired by slices in golang. Storage is thread-safe reference counted,
@@ -140,6 +145,9 @@ namespace epee
\throw std::out_of_range If `size() < end`.
\return Slice starting at `data() + begin` of size `end - begin`. */
byte_slice get_slice(std::size_t begin, std::size_t end) const;
+
+ //! \post `empty()` \return Ownership of ref-counted buffer.
+ std::unique_ptr<byte_slice_data, release_byte_slice> take_buffer() noexcept;
};
} // epee