From 77bcdc8127ead1e3a1682ded6988ca3ad88d68c1 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 28 Oct 2003 21:52:06 +0000 Subject: [PATCH] * vfs.c (mc_ungetlocalcopy): Free local path here, not in class implementations. * vfs.h (struct vfs_s_class): Constify "local" argument for ungetlocalcopy. Adjust all implementations. --- vfs/ChangeLog | 5 +++++ vfs/direntry.c | 5 ++--- vfs/extfs.c | 6 +++--- vfs/local.c | 4 ++-- vfs/sfs.c | 5 ++--- vfs/vfs.c | 5 ++--- vfs/vfs.h | 2 +- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index a325533f6..75962af87 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,5 +1,10 @@ 2003-10-28 Pavel Roskin + * vfs.c (mc_ungetlocalcopy): Free local path here, not in class + implementations. + * vfs.h (struct vfs_s_class): Constify "local" argument for + ungetlocalcopy. Adjust all implementations. + * direntry.c (vfs_s_init_class): Use our getlocalcopy for remote filesystems that cache files, not for archives. (vfs_s_getlocalcopy): Corresponding changes. diff --git a/vfs/direntry.c b/vfs/direntry.c index bafbb92a2..130af1e72 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -997,10 +997,9 @@ vfs_s_getlocalcopy (struct vfs_class *me, const char *path) * the cache will be removed when the archive is closed. */ static int -vfs_s_ungetlocalcopy (struct vfs_class *me, const char *path, char *local, - int has_changed) +vfs_s_ungetlocalcopy (struct vfs_class *me, const char *path, + const char *local, int has_changed) { - g_free (local); return 0; } diff --git a/vfs/extfs.c b/vfs/extfs.c index ce9e0faac..fd9e05ed2 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -191,7 +191,7 @@ static void extfs_free_archive (struct archive *archive) mc_stat (archive->local_name, &my); mc_ungetlocalcopy (archive->name, archive->local_name, archive->local_stat.st_mtime != my.st_mtime); - /* ungetlocalcopy frees local_name for us */ + /* mc_ungetlocalcopy() frees local_name for us */ } if (archive->name) g_free (archive->name); @@ -1254,8 +1254,8 @@ extfs_getlocalcopy (struct vfs_class *me, const char *path) } static int -extfs_ungetlocalcopy (struct vfs_class *me, const char *path, char *local, - int has_changed) +extfs_ungetlocalcopy (struct vfs_class *me, const char *path, + const char *local, int has_changed) { struct pseudofile *fp = (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0); diff --git a/vfs/local.c b/vfs/local.c index 4648cab22..7940aef9e 100644 --- a/vfs/local.c +++ b/vfs/local.c @@ -255,8 +255,8 @@ local_getlocalcopy (struct vfs_class *me, const char *path) } static int -local_ungetlocalcopy (struct vfs_class *me, const char *path, char *local, - int has_changed) +local_ungetlocalcopy (struct vfs_class *me, const char *path, + const char *local, int has_changed) { return 0; } diff --git a/vfs/sfs.c b/vfs/sfs.c index 09f42c9ed..530e2648e 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -301,10 +301,9 @@ sfs_getlocalcopy (struct vfs_class *me, const char *path) } static int -sfs_ungetlocalcopy (struct vfs_class *me, const char *path, char *local, - int has_changed) +sfs_ungetlocalcopy (struct vfs_class *me, const char *path, + const char *local, int has_changed) { - g_free (local); return 0; } diff --git a/vfs/vfs.c b/vfs/vfs.c index bece6a0b0..c4aaf25f0 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -1081,7 +1081,7 @@ mc_getlocalcopy (const char *pathname) static int mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename, - char *local, int has_changed) + const char *local, int has_changed) { int fdin = -1, fdout = -1, i; if (has_changed) { @@ -1114,7 +1114,6 @@ mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename, } } unlink (local); - g_free (local); return 0; failed: @@ -1124,7 +1123,6 @@ mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename, if (fdin != -1) close (fdin); unlink (local); - g_free (local); return -1; } @@ -1139,6 +1137,7 @@ mc_ungetlocalcopy (const char *pathname, char *local, int has_changed) (*vfs->ungetlocalcopy)(vfs, path, local, has_changed) : mc_def_ungetlocalcopy (vfs, path, local, has_changed); g_free (path); + g_free (local); return return_value; } diff --git a/vfs/vfs.h b/vfs/vfs.h index 84fae0862..469b87a53 100644 --- a/vfs/vfs.h +++ b/vfs/vfs.h @@ -72,7 +72,7 @@ struct vfs_class { char *(*getlocalcopy) (struct vfs_class *me, const char *filename); int (*ungetlocalcopy) (struct vfs_class *me, const char *filename, - char *local, int has_changed); + const char *local, int has_changed); int (*mkdir) (struct vfs_class *me, char *path, mode_t mode); int (*rmdir) (struct vfs_class *me, char *path);