kangkaisen commented on a change in pull request #3495:
URL: https://github.com/apache/incubator-doris/pull/3495#discussion_r420915050



##########
File path: be/src/util/path_util.cpp
##########
@@ -70,13 +70,19 @@ vector<string> split_path(const string& path) {
     return segments;
 }
 
+struct FreeDeleter {
+    inline void operator()(void* ptr) const {
+        free(ptr);
+    }
+};
+
 string dir_name(const string& path) {
-    std::unique_ptr<char[]> path_copy(strdup(path.c_str()));
+    std::unique_ptr<char[], FreeDeleter> path_copy(strdup(path.c_str()));

Review comment:
       Would better change to
   ```
   string dir_name(const string& path) {
       std::vector<char> path_copy(path.c_str(), path.c_str() + path.size() + 
1);
       return dirname(&path_copy[0]);
   }
   
   string base_name(const string& path) {
       std::vector<char> path_copy(path.c_str(), path.c_str() + path.size() + 
1);
       return basename(&path_copy[0]);
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to