void rename_files(const char* dir_path, rename_ptr renamefunc)
{
+ char* output = NULL;
+ char* dirname = NULL;
glob_t* files = get_files(dir_path);
for (int i = 0; i < files->gl_pathc; i++) {
- const char* output = renamefunc(files->gl_pathv[i]);
+ output = renamefunc(files->gl_pathv[i]);
rename_file(files->gl_pathv[i], output);
if (is_dir(output)) {
- const char* dirname = escape(output);
+ dirname = escape(output);
rename_files(dirname, renamefunc);
}
}
globfree(files);
free(files);
files = NULL;
+ free(output);
+ output = NULL;
+ free(dirname);
+ dirname = NULL;
}
int main(int argc, char* argv[])