From a7237c69f7befce7af174087bf770acd0187fb9b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 15 May 2016 23:40:09 +0900 Subject: Refactor BitTorrent message buffer usage --- src/SocketBuffer.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/SocketBuffer.h') diff --git a/src/SocketBuffer.h b/src/SocketBuffer.h index 8d9f3198..5858078f 100644 --- a/src/SocketBuffer.h +++ b/src/SocketBuffer.h @@ -40,6 +40,7 @@ #include #include #include +#include namespace aria2 { @@ -77,7 +78,7 @@ private: class ByteArrayBufEntry : public BufEntry { public: - ByteArrayBufEntry(unsigned char* bytes, size_t length, + ByteArrayBufEntry(std::vector bytes, std::unique_ptr progressUpdate); virtual ~ByteArrayBufEntry(); virtual ssize_t send(const std::shared_ptr& socket, @@ -87,8 +88,7 @@ private: virtual const unsigned char* getData() const CXX11_OVERRIDE; private: - unsigned char* bytes_; - size_t length_; + std::vector bytes_; }; class StringBufEntry : public BufEntry { @@ -123,13 +123,11 @@ public: SocketBuffer(const SocketBuffer&) = delete; SocketBuffer& operator=(const SocketBuffer&) = delete; - // Feeds data pointed by bytes with length len into queue. This - // object gets ownership of bytes, so caller must not delete or - // later bytes after this call. This function doesn't send data. If + // Feeds |bytes| into queue. This function doesn't send data. If // progressUpdate is not null, its update() function will be called // each time the data is sent. It will be deleted by this object. It // can be null. - void pushBytes(unsigned char* bytes, size_t len, + void pushBytes(std::vector bytes, std::unique_ptr progressUpdate = nullptr); // Feeds data into queue. This function doesn't send data. If -- cgit