replace bare pointer for a proper smart pointer;

pull/25/head
Bryan Biedenkapp 3 years ago
parent 53c36ce03e
commit 6225e54256

@ -133,8 +133,6 @@ namespace network
if (m_connection != nullptr) { if (m_connection != nullptr) {
m_connection->stop(); m_connection->stop();
delete m_connection;
m_connection = nullptr;
} }
wait(); wait();
@ -155,8 +153,6 @@ namespace network
if (m_connection != nullptr) { if (m_connection != nullptr) {
m_connection->stop(); m_connection->stop();
delete m_connection;
m_connection = nullptr;
} }
} }
@ -164,7 +160,7 @@ namespace network
void connect(asio::ip::basic_resolver_results<asio::ip::tcp>& endpoints) void connect(asio::ip::basic_resolver_results<asio::ip::tcp>& endpoints)
{ {
asio::connect(m_socket, endpoints); asio::connect(m_socket, endpoints);
m_connection = new ConnectionType(std::move(m_socket), m_requestHandler); m_connection = new_unique(ConnectionType, std::move(m_socket), m_requestHandler);
m_connection->start(); m_connection->start();
} }
@ -173,7 +169,7 @@ namespace network
typedef ConnectionImpl<RequestHandlerType> ConnectionType; typedef ConnectionImpl<RequestHandlerType> ConnectionType;
ConnectionType* m_connection; std::unique_ptr<ConnectionType> m_connection;
bool m_completed = false; bool m_completed = false;
asio::io_context m_ioContext; asio::io_context m_ioContext;

Loading…
Cancel
Save

Powered by TurnKey Linux.