From e7aa87f35c38473d3a4eb48fe3ceb06988bde36e Mon Sep 17 00:00:00 2001 From: Dominik Charousset Date: Sat, 11 Nov 2023 16:39:22 +0100 Subject: [PATCH] Bind scan_path to the scope; avoid heap allocation --- src/zeekygen/Target.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/zeekygen/Target.cc b/src/zeekygen/Target.cc index 519f4ccd24..a7e9b5bad7 100644 --- a/src/zeekygen/Target.cc +++ b/src/zeekygen/Target.cc @@ -439,15 +439,12 @@ vector dir_contents_recursive(string dir) { while ( dir[dir.size() - 1] == '/' ) dir.erase(dir.size() - 1, 1); - char** scan_path = new char*[2]; - scan_path[0] = dir.data(); - scan_path[1] = NULL; + char* scan_path[2] = {dir.data(), nullptr}; FTS* fts = fts_open(scan_path, FTS_NOCHDIR, 0); if ( ! fts ) { reporter->Error("fts_open failure: %s", strerror(errno)); - delete[] scan_path; return rval; } @@ -464,7 +461,6 @@ vector dir_contents_recursive(string dir) { if ( fts_close(fts) < 0 ) reporter->Error("fts_close failure: %s", strerror(errno)); - delete[] scan_path; return rval; }