adb: implement std::make_unique, start using it.
Add an implementation of std::make_unique for Windows, where we're
currently stuck with C++11, and switch some uses of new over to it.
Test: treehugger
Change-Id: I99b85f07754adda7c525243480c3e0bce9a25ce7
diff --git a/transport_local.cpp b/transport_local.cpp
index ff395dc..c09fcb7 100644
--- a/transport_local.cpp
+++ b/transport_local.cpp
@@ -45,6 +45,7 @@
#include "adb_unique_fd.h"
#include "adb_utils.h"
#include "sysdeps/chrono.h"
+#include "sysdeps/memory.h"
#if ADB_HOST
@@ -450,9 +451,8 @@
#if ADB_HOST
// Emulator connection.
if (local) {
- std::unique_ptr<BlockingConnection> emulator_connection(
- new EmulatorConnection(std::move(fd), adb_port));
- t->connection.reset(new BlockingConnectionAdapter(std::move(emulator_connection)));
+ auto emulator_connection = std::make_unique<EmulatorConnection>(std::move(fd), adb_port);
+ t->connection = std::make_unique<BlockingConnectionAdapter>(std::move(emulator_connection));
std::lock_guard<std::mutex> lock(local_transports_lock);
atransport* existing_transport = find_emulator_transport_by_adb_port_locked(adb_port);
if (existing_transport != NULL) {
@@ -471,7 +471,7 @@
#endif
// Regular tcp connection.
- std::unique_ptr<BlockingConnection> fd_connection(new FdConnection(std::move(fd)));
- t->connection.reset(new BlockingConnectionAdapter(std::move(fd_connection)));
+ auto fd_connection = std::make_unique<FdConnection>(std::move(fd));
+ t->connection = std::make_unique<BlockingConnectionAdapter>(std::move(fd_connection));
return fail;
}