Re: mcedit reentrancy and memory leaks in dir.c
- From: "Andrew V. Samoilov" <andrew email zp ua>
- To: Pavel Roskin <proski gnu org>
- Cc: mc-devel gnome org
- Subject: Re: mcedit reentrancy and memory leaks in dir.c
- Date: Fri, 24 Oct 2003 11:48:59 +0300 (EEST)
> On Thu, 23 Oct 2003, Andrew V. Samoilov wrote:
>
> > two patches to improve mcedit reentrancy and to fix some possible memory
> > leaks in src/dir.c.
>
> Applied.
>
> > BTW, what about moving tree_store_start_check_cwd() in do_(re)load_dir()
> > after mc_opendir() to eliminate one tree_store_end_check() ?
>
> Done.
Thanks!
One more patch to check mc_stat() return value and some trivial changes.
--
Regards,
Andrew V. Samoilov.
src/ChangeLog:
* dir.c (if_link_is_exe): Check mc_stat() return value.
Make full_name and file_entry const.
(link_isdir): Make file_entry const.
* dir.h: Adjust declarations.
--- dir.h~ Wed Oct 15 16:21:33 2003
+++ dir.h Fri Oct 24 11:25:00 2003
@@ -76,8 +76,8 @@
extern sort_orders_t sort_orders [SORT_TYPES_TOTAL];
-int link_isdir (file_entry *);
-int if_link_is_exe (char *full_name, file_entry *file);
+int link_isdir (const file_entry *);
+int if_link_is_exe (const char *full_name, const file_entry *file);
extern int show_backups;
extern int show_dot_files;
--- dir.c~ Fri Oct 24 10:01:33 2003
+++ dir.c Fri Oct 24 11:24:40 2003
@@ -477,7 +477,7 @@ do_load_dir (char *path, dir_list *list,
return set_zero_dir (list);
}
tree_store_start_check (path);
- for (dp = mc_readdir (dirp); dp; dp = mc_readdir (dirp)) {
+ while ((dp = mc_readdir (dirp))) {
status =
handle_dirent (list, filter, dp, &st, next_free, &link_to_dir,
&stale_link);
@@ -506,9 +506,7 @@ do_load_dir (char *path, dir_list *list,
add_dotdot_to_list (list, next_free++);
do_sort (list, sort, next_free - 1, reverse, case_sensitive);
} else {
- tree_store_end_check ();
- mc_closedir (dirp);
- return set_zero_dir (list);
+ next_free = set_zero_dir (list);
}
mc_closedir (dirp);
@@ -517,7 +515,7 @@ do_load_dir (char *path, dir_list *list,
}
int
-link_isdir (file_entry *file)
+link_isdir (const file_entry *file)
{
if (file->f.link_to_dir)
return 1;
@@ -526,12 +524,11 @@ link_isdir (file_entry *file)
}
int
-if_link_is_exe (char *full_name, file_entry *file)
+if_link_is_exe (const char *full_name, const file_entry *file)
{
struct stat b;
- if (S_ISLNK (file->st.st_mode)) {
- mc_stat (full_name, &b);
+ if (S_ISLNK (file->st.st_mode) && !mc_stat (full_name, &b)) {
return is_exe (b.st_mode);
} else
return 1;
@@ -632,9 +629,7 @@ do_reload_dir (char *path, dir_list *lis
* we copied one.
*/
if (marked_cnt > 0) {
- file_entry *p;
- if (NULL !=
- (p = g_hash_table_lookup (marked_files, dp->d_name))) {
+ if ((g_hash_table_lookup (marked_files, dp->d_name))) {
list->list[next_free].f.marked = 1;
marked_cnt--;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]