From d6a42e1823d6b2686e7ab56f2d21ef2f5689aec1 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 1 Jul 2022 15:24:23 +0900 Subject: THRIFT-5602: Use std::unique_ptr instead of boost::scoped_array Client: cpp We can use std::unique_ptr because we require C++11 or later. --- lib/cpp/src/thrift/transport/TBufferTransports.h | 9 ++++----- lib/cpp/src/thrift/transport/TFileTransport.cpp | 2 +- lib/cpp/src/thrift/transport/THeaderTransport.h | 4 +--- lib/cpp/test/TransportTest.cpp | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) (limited to 'lib/cpp') diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.h b/lib/cpp/src/thrift/transport/TBufferTransports.h index 3ef8d1f6a..f72d8f6bf 100644 --- a/lib/cpp/src/thrift/transport/TBufferTransports.h +++ b/lib/cpp/src/thrift/transport/TBufferTransports.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -281,8 +280,8 @@ protected: uint32_t rBufSize_; uint32_t wBufSize_; - boost::scoped_array rBuf_; - boost::scoped_array wBuf_; + std::unique_ptr rBuf_; + std::unique_ptr wBuf_; }; /** @@ -422,8 +421,8 @@ protected: uint32_t rBufSize_; uint32_t wBufSize_; - boost::scoped_array rBuf_; - boost::scoped_array wBuf_; + std::unique_ptr rBuf_; + std::unique_ptr wBuf_; uint32_t bufReclaimThresh_; uint32_t maxFrameSize_; }; diff --git a/lib/cpp/src/thrift/transport/TFileTransport.cpp b/lib/cpp/src/thrift/transport/TFileTransport.cpp index 08372b3e2..34fc1c29e 100644 --- a/lib/cpp/src/thrift/transport/TFileTransport.cpp +++ b/lib/cpp/src/thrift/transport/TFileTransport.cpp @@ -427,7 +427,7 @@ void TFileTransport::writerThread() { auto* zeros = new uint8_t[padding]; memset(zeros, '\0', padding); - boost::scoped_array array(zeros); + std::unique_ptr array(zeros); if (-1 == ::THRIFT_WRITE(fd_, zeros, padding)) { int errno_copy = THRIFT_ERRNO; GlobalOutput.perror("TFileTransport: writerThread() error while padding zeros ", diff --git a/lib/cpp/src/thrift/transport/THeaderTransport.h b/lib/cpp/src/thrift/transport/THeaderTransport.h index 63a4ac880..0343fe3e1 100644 --- a/lib/cpp/src/thrift/transport/THeaderTransport.h +++ b/lib/cpp/src/thrift/transport/THeaderTransport.h @@ -33,8 +33,6 @@ #include #endif -#include - #include #include #include @@ -223,7 +221,7 @@ protected: // Buffers to use for transform processing uint32_t tBufSize_; - boost::scoped_array tBuf_; + std::unique_ptr tBuf_; void readString(uint8_t*& ptr, /* out */ std::string& str, uint8_t const* headerBoundary); diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp index 085197a08..d6d38595a 100644 --- a/lib/cpp/test/TransportTest.cpp +++ b/lib/cpp/test/TransportTest.cpp @@ -379,7 +379,7 @@ void alarm_handler() { // Write some data to the transport to hopefully unblock it. auto* buf = new uint8_t[info->writeLength]; memset(buf, 'b', info->writeLength); - boost::scoped_array array(buf); + std::unique_ptr array(buf); info->transport->write(buf, info->writeLength); info->transport->flush(); -- cgit v1.2.1