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/adb/client/commandline.cpp b/adb/client/commandline.cpp
index d126f52..34930c6 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -61,6 +61,7 @@
#include "services.h"
#include "shell_service.h"
#include "sysdeps/chrono.h"
+#include "sysdeps/memory.h"
static int install_app(int argc, const char** argv);
static int install_multiple_app(int argc, const char** argv);
@@ -263,7 +264,7 @@
char raw_buffer[BUFSIZ];
char* buffer_ptr = raw_buffer;
if (use_shell_protocol) {
- protocol.reset(new ShellProtocol(fd));
+ protocol = std::make_unique<ShellProtocol>(fd);
if (!protocol) {
LOG(ERROR) << "failed to allocate memory for ShellProtocol object";
return 1;
@@ -630,7 +631,7 @@
args->raw_stdin = raw_stdin;
args->escape_char = escape_char;
if (use_shell_protocol) {
- args->protocol.reset(new ShellProtocol(args->write_fd));
+ args->protocol = std::make_unique<ShellProtocol>(args->write_fd);
}
if (raw_stdin) stdin_raw_init();