Change PBD::PathScanner API to return results by value to avoid inadvertent memory leaks

This commit is contained in:
Tim Mayberry 2014-06-16 20:39:45 +10:00
parent e426c603b6
commit 0e96d84079
14 changed files with 202 additions and 314 deletions

View file

@ -229,16 +229,12 @@ void
copy_files(const std::string & from_path, const std::string & to_dir)
{
PathScanner scanner;
vector<string*>* files = scanner (from_path, accept_all_files, 0, true, false);
vector<string> files = scanner (from_path, accept_all_files, 0, true, false);
if (files) {
for (vector<string*>::iterator i = files->begin(); i != files->end(); ++i) {
std::string from = Glib::build_filename (from_path, **i);
std::string to = Glib::build_filename (to_dir, **i);
copy_file (from, to);
}
vector_delete (files);
delete (files);
for (vector<string>::iterator i = files.begin(); i != files.end(); ++i) {
std::string from = Glib::build_filename (from_path, *i);
std::string to = Glib::build_filename (to_dir, *i);
copy_file (from, to);
}
}