Browse Source

* 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.

Pavel Roskin 21 years ago
parent
commit
77bcdc8127
7 changed files with 17 additions and 15 deletions
  1. 5 0
      vfs/ChangeLog
  2. 2 3
      vfs/direntry.c
  3. 3 3
      vfs/extfs.c
  4. 2 2
      vfs/local.c
  5. 2 3
      vfs/sfs.c
  6. 2 3
      vfs/vfs.c
  7. 1 1
      vfs/vfs.h

+ 5 - 0
vfs/ChangeLog

@@ -1,5 +1,10 @@
 2003-10-28  Pavel Roskin  <proski@gnu.org>
 
+	* 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.

+ 2 - 3
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;
 }
 

+ 3 - 3
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);

+ 2 - 2
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;
 }

+ 2 - 3
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;
 }
 

+ 2 - 3
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;
 }
 

+ 1 - 1
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);