diff --git a/include/tscore/ink_memory.h b/include/tscore/ink_memory.h index ae5dd3303e6..d461f9b9b89 100644 --- a/include/tscore/ink_memory.h +++ b/include/tscore/ink_memory.h @@ -236,7 +236,6 @@ can_safely_shift_left(T value, int num_places) @see ats_scoped_fd @see ats_scoped_mem - @see ats_scoped_obj For example, if you open a file descriptor and have to do other checks which result in having to call @c close in each @c if clause. @@ -585,36 +584,6 @@ class ats_scoped_mem : public ats_scoped_resource -class ats_scoped_obj : public ats_scoped_resource> -{ -public: - typedef ats_scoped_resource> super; ///< Super type. - typedef ats_scoped_obj self; ///< Self reference. - - /// Default constructor - an empty container. - ats_scoped_obj() : super() {} - /// Construct with contained resource. - explicit ats_scoped_obj(T *obj) : super(obj) {} - self & - operator=(T *obj) - { - super::operator=(obj); - return *this; - } - - T * - operator->() const - { - return *this; - } -}; - /** Combine two strings as file paths. Trailing and leading separators for @a lhs and @a rhs respectively are handled to yield exactly one separator. diff --git a/iocore/net/SSLSessionCache.cc b/iocore/net/SSLSessionCache.cc index aa8dc7dcf32..38c4d29d124 100644 --- a/iocore/net/SSLSessionCache.cc +++ b/iocore/net/SSLSessionCache.cc @@ -24,6 +24,7 @@ #include "SSLStats.h" #include +#include #define SSLSESSIONCACHE_STRINGIFY0(x) #x #define SSLSESSIONCACHE_STRINGIFY(x) SSLSESSIONCACHE_STRINGIFY0(x) @@ -160,7 +161,7 @@ SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess, SSL * // This could be moved to a function in charge of populating exdata exdata->curve = (ssl == nullptr) ? 0 : SSLGetCurveNID(ssl); - ats_scoped_obj ssl_session(new SSLSession(id, buf, len, buf_exdata)); + std::unique_ptr ssl_session(new SSLSession(id, buf, len, buf_exdata)); std::unique_lock w_lock(mutex, std::try_to_lock); if (!w_lock.owns_lock()) { @@ -351,7 +352,7 @@ SSLOriginSessionCache::insert_session(const std::string &lookup_key, SSL_SESSION // Create the shared pointer to the session, with the custom deleter std::shared_ptr shared_sess(sess_ptr, SSLSessDeleter); ssl_curve_id curve = (ssl == nullptr) ? 0 : SSLGetCurveNID(ssl); - ats_scoped_obj ssl_orig_session(new SSLOriginSession(lookup_key, curve, shared_sess)); + std::unique_ptr ssl_orig_session(new SSLOriginSession(lookup_key, curve, shared_sess)); auto new_node = ssl_orig_session.release(); std::unique_lock lock(mutex); diff --git a/plugins/experimental/sslheaders/sslheaders.cc b/plugins/experimental/sslheaders/sslheaders.cc index 92b42992340..933131b0ac2 100644 --- a/plugins/experimental/sslheaders/sslheaders.cc +++ b/plugins/experimental/sslheaders/sslheaders.cc @@ -215,7 +215,7 @@ SslHdrParseOptions(int argc, const char **argv) {nullptr, 0, nullptr, 0}, }; - ats_scoped_obj hdr(new SslHdrInstance()); + std::unique_ptr hdr(new SslHdrInstance()); for (;;) { int opt; diff --git a/proxy/http2/unit_tests/test_HpackIndexingTable.cc b/proxy/http2/unit_tests/test_HpackIndexingTable.cc index d750015faed..75ec83a0619 100644 --- a/proxy/http2/unit_tests/test_HpackIndexingTable.cc +++ b/proxy/http2/unit_tests/test_HpackIndexingTable.cc @@ -24,6 +24,8 @@ limitations under the License. */ +#include + #include "catch.hpp" #include "HPACK.h" @@ -69,7 +71,7 @@ TEST_CASE("HPACK low level APIs", "[hpack]") HpackIndexingTable indexing_table(4096); for (const auto &i : indexed_test_case) { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_REQUEST); MIMEField *field = mime_field_create(headers->m_heap, headers->m_http->m_fields_impl); MIMEFieldWrapper header(field, headers->m_heap, headers->m_http->m_fields_impl); @@ -222,7 +224,7 @@ TEST_CASE("HPACK low level APIs", "[hpack]") HpackIndexingTable indexing_table(4096); for (const auto &i : literal_test_case) { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_REQUEST); MIMEField *field = mime_field_create(headers->m_heap, headers->m_http->m_fields_impl); MIMEFieldWrapper header(field, headers->m_heap, headers->m_http->m_fields_impl); @@ -347,7 +349,7 @@ TEST_CASE("HPACK high level APIs", "[hpack]") indexing_table.update_maximum_size(DYNAMIC_TABLE_SIZE_FOR_REGRESSION_TEST); for (unsigned int i = 0; i < sizeof(encoded_field_response_test_case) / sizeof(encoded_field_response_test_case[0]); i++) { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_RESPONSE); for (unsigned int j = 0; j < sizeof(raw_field_response_test_case[i]) / sizeof(raw_field_response_test_case[i][0]); j++) { @@ -365,7 +367,7 @@ TEST_CASE("HPACK high level APIs", "[hpack]") memset(buf, 0, BUFSIZE_FOR_REGRESSION_TEST); uint64_t buf_len = BUFSIZE_FOR_REGRESSION_TEST; - int64_t len = hpack_encode_header_block(indexing_table, buf, buf_len, headers); + int64_t len = hpack_encode_header_block(indexing_table, buf, buf_len, headers.get()); REQUIRE(len > 0); REQUIRE(len == encoded_field_response_test_case[i].encoded_field_len); @@ -453,10 +455,10 @@ TEST_CASE("HPACK high level APIs", "[hpack]") HpackIndexingTable indexing_table(4096); for (unsigned int i = 0; i < sizeof(encoded_field_request_test_case) / sizeof(encoded_field_request_test_case[0]); i++) { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_REQUEST); - hpack_decode_header_block(indexing_table, headers, encoded_field_request_test_case[i].encoded_field, + hpack_decode_header_block(indexing_table, headers.get(), encoded_field_request_test_case[i].encoded_field, encoded_field_request_test_case[i].encoded_field_len, MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); for (unsigned int j = 0; j < sizeof(raw_field_request_test_case[i]) / sizeof(raw_field_request_test_case[i][0]); j++) { @@ -486,14 +488,15 @@ TEST_CASE("HPACK high level APIs", "[hpack]") // add entries in dynamic table { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_REQUEST); // C.3.1. First Request uint8_t data[] = {0x82, 0x86, 0x84, 0x41, 0x0f, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d}; - int64_t len = hpack_decode_header_block(indexing_table, headers, data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); + int64_t len = + hpack_decode_header_block(indexing_table, headers.get(), data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); CHECK(len == sizeof(data)); CHECK(indexing_table.maximum_size() == 4096); CHECK(indexing_table.size() == 57); @@ -501,12 +504,13 @@ TEST_CASE("HPACK high level APIs", "[hpack]") // clear all entries by setting a maximum size of 0 { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_REQUEST); uint8_t data[] = {0x20}; - int64_t len = hpack_decode_header_block(indexing_table, headers, data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); + int64_t len = + hpack_decode_header_block(indexing_table, headers.get(), data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); CHECK(len == sizeof(data)); CHECK(indexing_table.maximum_size() == 0); CHECK(indexing_table.size() == 0); @@ -514,12 +518,13 @@ TEST_CASE("HPACK high level APIs", "[hpack]") // make the maximum size back to 4096 { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_REQUEST); uint8_t data[] = {0x3f, 0xe1, 0x1f}; - int64_t len = hpack_decode_header_block(indexing_table, headers, data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); + int64_t len = + hpack_decode_header_block(indexing_table, headers.get(), data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); CHECK(len == sizeof(data)); CHECK(indexing_table.maximum_size() == 4096); CHECK(indexing_table.size() == 0); @@ -527,12 +532,13 @@ TEST_CASE("HPACK high level APIs", "[hpack]") // error with exceeding the limit (MAX_TABLE_SIZE) { - ats_scoped_obj headers(new HTTPHdr); + std::unique_ptr headers(new HTTPHdr); headers->create(HTTP_TYPE_REQUEST); uint8_t data[] = {0x3f, 0xe2, 0x1f}; - int64_t len = hpack_decode_header_block(indexing_table, headers, data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); + int64_t len = + hpack_decode_header_block(indexing_table, headers.get(), data, sizeof(data), MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE); CHECK(len == HPACK_ERROR_COMPRESSION_ERROR); } } diff --git a/proxy/logging/LogFilter.cc b/proxy/logging/LogFilter.cc index 6371b9b1791..a16d2d60910 100644 --- a/proxy/logging/LogFilter.cc +++ b/proxy/logging/LogFilter.cc @@ -26,6 +26,9 @@ ***************************************************************************/ + +#include + #include "tscore/ink_platform.h" #include "LogUtils.h" @@ -69,7 +72,7 @@ LogFilter * LogFilter::parse(const char *name, Action action, const char *condition) { SimpleTokenizer tok(condition); - ats_scoped_obj logfield; + std::unique_ptr logfield; ink_release_assert(action != N_ACTIONS); @@ -95,7 +98,7 @@ LogFilter::parse(const char *name, Action action, const char *condition) } if (LogField *f = Log::global_field_list.find_by_symbol(field_str)) { - logfield = new LogField(*f); + logfield.reset(new LogField(*f)); } if (!logfield) { @@ -127,7 +130,7 @@ LogFilter::parse(const char *name, Action action, const char *condition) return nullptr; } - logfield = new LogField(fname, container); + logfield.reset(new LogField(fname, container)); ink_assert(logfield != nullptr); } } @@ -157,7 +160,7 @@ LogFilter::parse(const char *name, Action action, const char *condition) switch (field_type) { case LogField::sINT: - filter = new LogFilterInt(name, logfield, action, oper, val_str); + filter = new LogFilterInt(name, logfield.get(), action, oper, val_str); break; case LogField::dINT: @@ -165,11 +168,11 @@ LogFilter::parse(const char *name, Action action, const char *condition) return nullptr; case LogField::STRING: - filter = new LogFilterString(name, logfield, action, oper, val_str); + filter = new LogFilterString(name, logfield.get(), action, oper, val_str); break; case LogField::IP: - filter = new LogFilterIP(name, logfield, action, oper, val_str); + filter = new LogFilterIP(name, logfield.get(), action, oper, val_str); break; default: