Use make_unique when appropriate
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 25 May 2020 19:08:43 +0000 (21:08 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 25 May 2020 19:08:43 +0000 (21:08 +0200)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/csync/vio/csync_vio_local_unix.cpp
src/csync/vio/csync_vio_local_win.cpp

index addfd6ed28e60c009fdeb38fcbd9b348ed48e109..17049746342369293f124e769d09b424f25887b8 100644 (file)
@@ -26,6 +26,8 @@
 #include <dirent.h>
 #include <stdio.h>
 
+#include <memory>
+
 #include "c_private.h"
 #include "c_lib.h"
 #include "c_string.h"
@@ -101,7 +103,7 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *d
           return {};
   } while (qstrcmp(dirent->d_name, ".") == 0 || qstrcmp(dirent->d_name, "..") == 0);
 
-  file_stat.reset(new csync_file_stat_t);
+  file_stat = std::make_unique<csync_file_stat_t>();
   file_stat->path = c_utf8_from_locale(dirent->d_name);
   QByteArray fullPath = QByteArray() % const_cast<const char *>(handle->path) % '/' % QByteArray() % const_cast<const char *>(dirent->d_name);
   if (file_stat->path.isNull()) {
index 1c8e0592078999713f3715028d4ee159cf70f9b7..9955c230ee2fdd5af8633635bec2a69d6f05d0d0 100644 (file)
@@ -25,6 +25,8 @@
 #include <fcntl.h>
 #include <stdio.h>
 
+#include <memory>
+
 #include "windows.h"
 
 #include "c_private.h"
@@ -166,7 +168,7 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *d
   if (path == "." || path == "..")
       return csync_vio_local_readdir(dhandle);
 
-  file_stat.reset(new csync_file_stat_t);
+  file_stat = std::make_unique<csync_file_stat_t>();
   file_stat->path = path;
 
   if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {