changeset 598:fa0838b22b14

2004-10-29 Brian Masney <masneyb@gftp.org> * lib/gftp.h lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c src/gtk/dnd.c src/gtk/view_dialog.c src/uicommon/gftpui.c src/uicommon/gftpuicallbacks.c - removed free_fdata(). Added free_it parameter to gftp_file_destroy()
author masneyb
date Fri, 29 Oct 2004 20:05:32 +0000
parents 83f6f9c37d0d
children 0999b11f84e3
files ChangeLog lib/gftp.h lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c src/gtk/dnd.c src/gtk/view_dialog.c src/uicommon/gftpui.c src/uicommon/gftpuicallbacks.c
diffstat 11 files changed, 38 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Oct 27 22:18:30 2004 +0000
+++ b/ChangeLog	Fri Oct 29 20:05:32 2004 +0000
@@ -1,3 +1,9 @@
+2004-10-29 Brian Masney <masneyb@gftp.org>
+	* lib/gftp.h lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c
+	lib/sshv2.c src/gtk/dnd.c src/gtk/view_dialog.c src/uicommon/gftpui.c
+	src/uicommon/gftpuicallbacks.c - removed free_fdata(). Added
+	free_it parameter to gftp_file_destroy()
+
 2004-10-27 Brian Masney <masneyb@gftp.org>
 	* docs/website/index.html.in - updated the list of available
 	translations
@@ -2961,7 +2967,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.347 2004/10/27 22:18:29 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.348 2004/10/29 20:05:31 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Wed Oct 27 22:18:30 2004 +0000
+++ b/lib/gftp.h	Fri Oct 29 20:05:32 2004 +0000
@@ -749,8 +749,6 @@
 
 void free_file_list			( GList * filelist );
 
-void free_fdata				( gftp_file * fle );
-
 gftp_file * copy_fdata 			( gftp_file * fle );
 
 int compare_request 			( gftp_request * request1, 
@@ -859,7 +857,8 @@
 void gftp_copy_param_options		( gftp_request * dest_request,
 					  gftp_request * src_request );
 
-void gftp_file_destroy 			( gftp_file *file );
+void gftp_file_destroy 			( gftp_file *file,
+					  int free_it );
 
 int gftp_connect 			( gftp_request * request );
 
--- a/lib/misc.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/lib/misc.c	Fri Oct 29 20:05:32 2004 +0000
@@ -434,32 +434,13 @@
   while (templist != NULL)
     {
       tempfle = templist->data;
-      free_fdata (tempfle);
+      gftp_file_destroy (tempfle, 1);
       templist = templist->next;
     }
   g_list_free (filelist);
 }
 
 
-void
-free_fdata (gftp_file * fle)
-{
-  if (fle->file)
-    g_free (fle->file);
-  if (fle->utf8_file)
-    g_free (fle->utf8_file);
-  if (fle->user)
-    g_free (fle->user);
-  if (fle->group)
-    g_free (fle->group);
-  if (fle->destfile)
-    g_free (fle->destfile);
-  if (fle->fd > 0)
-    close (fle->fd);
-  g_free (fle);
-}
-
-
 gftp_file *
 copy_fdata (gftp_file * fle)
 {
--- a/lib/protocols.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/lib/protocols.c	Fri Oct 29 20:05:32 2004 +0000
@@ -100,7 +100,7 @@
 
 
 void
-gftp_file_destroy (gftp_file * file)
+gftp_file_destroy (gftp_file * file, int free_it)
 {
   g_return_if_fail (file != NULL);
 
@@ -114,7 +114,11 @@
     g_free (file->group);
   if (file->destfile)
     g_free (file->destfile);
-  memset (file, 0, sizeof (*file));
+
+  if (free_it)
+    g_free (file);
+  else
+    memset (file, 0, sizeof (*file));
 }
 
 
@@ -442,8 +446,8 @@
 gftp_string_to_utf8 (gftp_request * request, const char *str)
 {
   char *ret, *remote_charsets, *stpos, *cur_charset, *tempstr;
+  GError * error = NULL;
   gsize bread, bwrite;
-  GError * error;
 
   if (request == NULL)
     return (NULL);
@@ -511,8 +515,8 @@
 gftp_string_from_utf8 (gftp_request * request, const char *str)
 {
   char *ret, *remote_charsets, *stpos, *cur_charset, *tempstr;
+  GError * error = NULL;
   gsize bread, bwrite;
-  GError * error;
 
   if (request == NULL)
     return (NULL);
@@ -614,7 +618,7 @@
   memset (fle, 0, sizeof (*fle));
   do
     {
-      gftp_file_destroy (fle);
+      gftp_file_destroy (fle, 0);
       ret = request->get_next_file (request, fle, fd);
 
       if (ret >= 0 && fle->file != NULL)
@@ -1847,7 +1851,7 @@
           *newsize = fle->size;
           g_hash_table_insert (dirhash, newname, newsize);
           fle->file = NULL;
-          gftp_file_destroy (fle);
+          gftp_file_destroy (fle, 0);
         }
       gftp_end_transfer (request);
       g_free (fle);
@@ -1907,7 +1911,7 @@
     {
       if (strcmp (fle->file, ".") == 0 || strcmp (fle->file, "..") == 0)
         {
-          gftp_file_destroy (fle);
+          gftp_file_destroy (fle, 0);
           continue;
         }
 
@@ -1938,8 +1942,7 @@
     }
   gftp_end_transfer (transfer->fromreq);
 
-  gftp_file_destroy (fle);
-  g_free (fle);
+  gftp_file_destroy (fle, 1);
 
   if (dirhash != NULL)
     gftp_destroy_dir_hash (dirhash);
--- a/lib/rfc2068.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/lib/rfc2068.c	Fri Oct 29 20:05:32 2004 +0000
@@ -614,14 +614,14 @@
         return (ret);
 
       if (parse_html_line (tempstr, fle) == 0 || fle->file == NULL)
-	gftp_file_destroy (fle);
+	gftp_file_destroy (fle, 0);
       else
 	break;
     }
 
   if (fle->file == NULL)
     {
-      gftp_file_destroy (fle);
+      gftp_file_destroy (fle, 0);
       return (0);
     }
 
--- a/lib/rfc959.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/lib/rfc959.c	Fri Oct 29 20:05:32 2004 +0000
@@ -1509,7 +1509,7 @@
                                           sizeof (tempstr));
       if (len <= 0)
 	{
-          gftp_file_destroy (fle);
+          gftp_file_destroy (fle, 0);
 	  return (len);
 	} 
 
@@ -1520,7 +1520,7 @@
 	    request->logging_function (gftp_logging_error, request,
 				       _("Warning: Cannot parse listing %s\n"),
 				       tempstr);
-	  gftp_file_destroy (fle);
+	  gftp_file_destroy (fle, 0);
 	  continue;
 	}
       else
--- a/lib/sshv2.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/lib/sshv2.c	Fri Oct 29 20:05:32 2004 +0000
@@ -1351,14 +1351,14 @@
                                      _("Warning: Cannot parse listing %s\n"),
                                      longname);
 
-          gftp_file_destroy (fle);
+          gftp_file_destroy (fle, 0);
           return (ret);
         }
 
       if ((ret = sshv2_decode_file_attributes (request, &params->message,
                                                fle)) < 0)
         {
-          gftp_file_destroy (fle);
+          gftp_file_destroy (fle, 0);
           return (ret);
         }
 
@@ -1704,7 +1704,7 @@
   message.pos += 4;
   if ((ret = sshv2_decode_file_attributes (request, &message, fle)) < 0)
     {
-      gftp_file_destroy (fle);
+      gftp_file_destroy (fle, 0);
       return (ret);
     }
 
@@ -1727,7 +1727,7 @@
     return (ret);
 
   *mode = fle.st_mode;
-  gftp_file_destroy (&fle);
+  gftp_file_destroy (&fle, 0);
 
   return (0);
 }
@@ -1746,7 +1746,7 @@
     return (ret);
 
   size = fle.size;
-  gftp_file_destroy (&fle);
+  gftp_file_destroy (&fle, 0);
 
   return (size);
 }
--- a/src/gtk/dnd.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/src/gtk/dnd.c	Fri Oct 29 20:05:32 2004 +0000
@@ -54,7 +54,7 @@
       (pos = strrchr (current_ftpdata->directory, '/')) == NULL) 
     {
       gftp_request_destroy (current_ftpdata, 1);
-      free_fdata (newfle);
+      gftp_file_destroy (newfle, 1);
       return (0);
     }
 
@@ -62,7 +62,7 @@
   if (compare_request (current_ftpdata, wdata->request, 1))
     {
       gftp_request_destroy (current_ftpdata, 1);
-      free_fdata (newfle);
+      gftp_file_destroy (newfle, 1);
       return (0);
     }
 
--- a/src/gtk/view_dialog.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/src/gtk/view_dialog.c	Fri Oct 29 20:05:32 2004 +0000
@@ -75,7 +75,7 @@
           ftp_log (gftp_logging_misc, NULL, 
                    _("Error: Cannot open %s for writing: %s\n"),  
                    new_fle->destfile, g_strerror (errno));
-          free_fdata (new_fle);
+          gftp_file_destroy (new_fle, 1);
           return;
         }
 
@@ -154,7 +154,7 @@
           ftp_log (gftp_logging_misc, NULL, 
                    _("Error: Cannot open %s for writing: %s\n"),
                    new_fle->destfile, g_strerror (errno));
-          free_fdata (new_fle);
+          gftp_file_destroy (new_fle, 1);
           return;
         }
 
--- a/src/uicommon/gftpui.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/src/uicommon/gftpui.c	Fri Oct 29 20:05:32 2004 +0000
@@ -631,8 +631,7 @@
       g_free (tempstr);
 
       templist = templist->next;
-      gftp_file_destroy (fle);
-      g_free (fle);
+      gftp_file_destroy (fle, 1);
     }
 
 
@@ -897,7 +896,7 @@
     {
       if (strcmp (fle->file, ".") == 0 || strcmp (fle->file, "..") == 0)
         {
-          gftp_file_destroy (fle);
+          gftp_file_destroy (fle, 0);
           continue;
         }
 
--- a/src/uicommon/gftpuicallbacks.c	Wed Oct 27 22:18:30 2004 +0000
+++ b/src/uicommon/gftpuicallbacks.c	Fri Oct 29 20:05:32 2004 +0000
@@ -85,7 +85,7 @@
 
       if (got < 0 || strcmp (fle->file, ".") == 0 || !matched_filespec)
         {
-          gftp_file_destroy (fle);
+          gftp_file_destroy (fle, 0);
           continue;
         }
       else if (strcmp (fle->file, "..") == 0)