gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3834 - in gnunet-gtk/src: common plugins/fs


From: grothoff
Subject: [GNUnet-SVN] r3834 - in gnunet-gtk/src: common plugins/fs
Date: Thu, 30 Nov 2006 09:42:44 -0800 (PST)

Author: grothoff
Date: 2006-11-30 09:42:39 -0800 (Thu, 30 Nov 2006)
New Revision: 3834

Modified:
   gnunet-gtk/src/common/helper.c
   gnunet-gtk/src/common/iterators.c
   gnunet-gtk/src/common/logging.c
   gnunet-gtk/src/plugins/fs/download.c
   gnunet-gtk/src/plugins/fs/fs.c
   gnunet-gtk/src/plugins/fs/meta.c
   gnunet-gtk/src/plugins/fs/namespace.c
   gnunet-gtk/src/plugins/fs/search.c
Log:
leaks

Modified: gnunet-gtk/src/common/helper.c
===================================================================
--- gnunet-gtk/src/common/helper.c      2006-11-30 16:27:35 UTC (rev 3833)
+++ gnunet-gtk/src/common/helper.c      2006-11-30 17:42:39 UTC (rev 3834)
@@ -60,12 +60,6 @@
 
 static char * gladeFile;
 
-static GladeXML * statusXML;
-
-static GtkWidget * infoWindow;
-
-static GtkWidget * infoWindowTextView;
-
 static GdkWindowState main_window_state;
 
 /**
@@ -320,16 +314,6 @@
                         GE_FATAL | GE_USER | GE_IMMEDIATE,
                         "glade_xml_new",
                         gladeFile);
-  statusXML
-    = glade_xml_new(getGladeFileName(),
-                   "statusWindow",
-                   PACKAGE_NAME);
-  infoWindow
-    = glade_xml_get_widget(statusXML,
-                          "statusWindow");
-  infoWindowTextView
-    = glade_xml_get_widget(statusXML,
-                          "messageWindowTextView");
   /* load the plugins */
   GC_get_configuration_value_string(cfg,
                                    "GNUNET-GTK",
@@ -339,7 +323,6 @@
   loadPlugins(load);
   FREE(load);
   connectGladeWithPlugins(mainXML);
-  connectGladeWithPlugins(statusXML);
 }
 
 void shutdownPlugins() {
@@ -353,9 +336,6 @@
     unloadPlugin(plugin);
     plugin = next;
   }
-  gtk_widget_destroy(infoWindow);
-  infoWindow = NULL;
-  UNREF(statusXML);
   UNREF(mainXML);
   mainXML = NULL;
   FREE(gladeFile);

Modified: gnunet-gtk/src/common/iterators.c
===================================================================
--- gnunet-gtk/src/common/iterators.c   2006-11-30 16:27:35 UTC (rev 3833)
+++ gnunet-gtk/src/common/iterators.c   2006-11-30 17:42:39 UTC (rev 3834)
@@ -23,7 +23,10 @@
  * @author Igor Wronsky
  * @author Christian Grothoff
  */
-
+#include "platform.h"
+#include "gnunetgtk_common.h"
+#include <GNUnet/gnunet_util_crypto.h>
+#include <glib.h>
 /**
  * Identical to "gtk_tree_selection_selected_foreach",
  * except that modifications of the underlying model

Modified: gnunet-gtk/src/common/logging.c
===================================================================
--- gnunet-gtk/src/common/logging.c     2006-11-30 16:27:35 UTC (rev 3833)
+++ gnunet-gtk/src/common/logging.c     2006-11-30 17:42:39 UTC (rev 3834)
@@ -30,6 +30,28 @@
 #include <glib.h>
 #include <gmodule.h>
 
+static GtkWidget * infoWindow;
+
+static GtkWidget * infoWindowTextView;
+
+static GladeXML * statusXML;
+
+static void init() {
+  if (statusXML != NULL) 
+    return;
+  statusXML
+    = glade_xml_new(getGladeFileName(),
+                   "statusWindow",
+                   PACKAGE_NAME);
+  infoWindow
+    = glade_xml_get_widget(statusXML,
+                          "statusWindow");
+  infoWindowTextView
+    = glade_xml_get_widget(statusXML,
+                          "messageWindowTextView");
+  connectGladeWithPlugins(statusXML);
+}
+
 /**
  * Closure for doInfoMessage.
  */
@@ -46,6 +68,7 @@
   GtkTextIter iter;
   GtkTextBuffer * buffer;
 
+  init();
   if (info->doPopup==YES)
     gtk_widget_show(infoWindow);
   buffer
@@ -83,9 +106,10 @@
   static int once = 1;
   static guint id;
 
+  init();
   if (once) {
     once = 0;
-    s = glade_xml_get_widget(mainXML,
+    s = glade_xml_get_widget(getMainXML(),
                             "statusbar");
     id = gtk_statusbar_get_context_id(GTK_STATUSBAR(s),
                                      "LOG");
@@ -118,3 +142,11 @@
   g_free(note);
 }
 
+void __attribute__ ((destructor)) gnunet_crypto_ltdl_fini() {
+  if (statusXML != NULL) {
+    gtk_widget_destroy(infoWindow);
+    infoWindow = NULL;
+    UNREF(statusXML);
+    statusXML = NULL;
+  }
+}

Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c        2006-11-30 16:27:35 UTC (rev 
3833)
+++ gnunet-gtk/src/plugins/fs/download.c        2006-11-30 17:42:39 UTC (rev 
3834)
@@ -396,7 +396,7 @@
              GtkTreeIter * parent) {
   GtkTreeModel * model;
   GtkTreeIter iter;
-  const char * name;
+  char * name;
 
   model = GTK_TREE_MODEL(download_summary);
   if (gtk_tree_model_iter_children(model,
@@ -408,8 +408,11 @@
                         DOWNLOAD_FILENAME, &name,
                         -1);
       if ( (name != NULL) &&
-          (0 == strcmp(name, filename)) )
+          (0 == strcmp(name, filename)) ) {
+       FREE(name);
        return SYSERR;
+      }
+      FREENONNULL(name);
       if (SYSERR == check_pending(filename,
                                  &iter))
        return SYSERR;
@@ -431,24 +434,20 @@
   char * uri_name;
   char * final_download_dir;
   GtkTreeIter iiter;
-  const char * oname;
-  const char * cname;
+  char * tmp;
+  char * cname;
   char * dname;
   GtkTreePath *dirTreePath;
   char *dirPath;
   unsigned int dirPathLen;
   struct ECRS_URI * idc_uri;
   struct ECRS_MetaData * idc_meta;
-  const char * idc_name;
-  const char * idc_mime;
+  char * idc_name;
+  char * idc_mime;
   char * idc_final_download_destination;
   SearchList * searchContext;
   DownloadList * parentContext;
 
-#ifdef WINDOWS
-  char *filehash = NULL;
-#endif
-
   DEBUG_BEGIN();
   idc_uri = NULL;
   idc_meta = NULL;
@@ -468,6 +467,8 @@
   if ( (idc_uri == NULL) ||
        (! ECRS_isFileUri(idc_uri)) ) {
     GE_BREAK(ectx, 0);
+    FREENONNULL(idc_name);
+    FREENONNULL(idc_mime);
     return;
   }
   uri_name = ECRS_uriToString(idc_uri);
@@ -477,40 +478,39 @@
         strlen(ECRS_FILE_INFIX)) ) {
     GE_BREAK(ectx, 0);
     FREENONNULL(uri_name);
+    FREENONNULL(idc_name);
+    FREENONNULL(idc_mime);
     return;
   }
   if (idc_name == NULL) {
 #ifdef WINDOWS
+    char * filehash;
+    
     filehash = STRDUP(uri_name);
     filehash[16] = 0;
-    idc_name = filehash;
+    idc_name = STRDUP(filehash);
+    FREENONNULL(filehash);
 #else
-    idc_name = uri_name;
+    idc_name = STRDUP(uri_name);
 #endif
   }
+
+  /* dname = directory portion of idc_name */  
   cname = idc_name;
-  oname = idc_name;
-  dname = MALLOC(strlen(idc_name)+1);
-  dname[0] = '\0';
-  while (*idc_name != '\0') {
-    if ( (*idc_name == DIR_SEPARATOR) &&
-        (idc_name[1] != '\0') ) {
-      memcpy(dname, oname, idc_name - oname);
-      dname[idc_name - oname] = '\0';
-      cname = &idc_name[1];
-    }
-    idc_name++;
-  }
-  if (*cname == '\0') /* name ended in '/' - likely directory */
-    cname = oname;
-  idc_name = cname;
+  dname = STRDUP(idc_name);
+  cname = &dname[strlen(dname)-1];
+  while ( (cname != dname) &&
+         (*cname != DIR_SEPARATOR) )
+    cname--;
+  *cname = '\0';
+  cname = NULL;
+
   GC_get_configuration_value_filename(cfg,
                                      "FS",
                                      "INCOMINGDIR",
                                      "$HOME/gnunet-downloads/",
                                      &final_download_dir);
   if (strlen(dname) > 0) {
-    char * tmp;
     tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2);
     strcpy(tmp, final_download_dir);
     if (tmp[strlen(tmp)] != DIR_SEPARATOR)
@@ -523,6 +523,7 @@
     final_download_dir = tmp;
   }
   FREE(dname);
+  dname = NULL;
   disk_directory_create(ectx, final_download_dir);
 
 
@@ -562,11 +563,13 @@
   idc_final_download_destination = MALLOC(strlen(final_download_dir) + 2 +
                                          strlen(idc_name) + 
strlen(GNUNET_DIRECTORY_EXT) +
                                          strlen(dirPath));
-  strcpy(idc_final_download_destination, final_download_dir);
+  strcpy(idc_final_download_destination, 
+        final_download_dir);
   if (idc_final_download_destination[strlen(idc_final_download_destination)-1] 
!= DIR_SEPARATOR)
     strcat(idc_final_download_destination,
            DIR_SEPARATOR_STR);
-  strcat(idc_final_download_destination, dirPath);
+  strcat(idc_final_download_destination, 
+        dirPath);
   disk_directory_create(ectx,
                        idc_final_download_destination);
   strcat(idc_final_download_destination, idc_name);
@@ -601,10 +604,10 @@
   }
   FREE(uri_name);
   FREE(dirPath);
+  FREE(idc_final_download_destination);
   FREENONNULL(final_download_dir);
-#ifdef WINDOWS
-  FREENONNULL(filehash);
-#endif
+  FREENONNULL(idc_name);
+  FREENONNULL(idc_mime);
 }
 
 /**
@@ -756,7 +759,7 @@
 }
 
 void on_abortDownloadButton_clicked_fs(void * unused,
-                                      GtkWidget * clearButton) {
+                                      GtkWidget * abortButton) {
   GtkTreeSelection * selection;
   GtkWidget * downloadList;
 
@@ -770,7 +773,7 @@
 }
 
 void on_stopDownloadButton_clicked_fs(void * unused,
-                                     GtkWidget * clearButton) {
+                                     GtkWidget * stopButton) {
   GtkTreeSelection * selection;
   GtkWidget * downloadList;
 

Modified: gnunet-gtk/src/plugins/fs/fs.c
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.c      2006-11-30 16:27:35 UTC (rev 3833)
+++ gnunet-gtk/src/plugins/fs/fs.c      2006-11-30 17:42:39 UTC (rev 3834)
@@ -437,7 +437,7 @@
   ctx = FSUI_start(ectx,
                   cfg,
                   "gnunet-gtk",
-                  128, /* FIXME: allow user to configure download parallelism 
*/
+                  8, /* FIXME: allow user to configure download parallelism */
                   YES,
                   &eventProcessor,
                   NULL);

Modified: gnunet-gtk/src/plugins/fs/meta.c
===================================================================
--- gnunet-gtk/src/plugins/fs/meta.c    2006-11-30 16:27:35 UTC (rev 3833)
+++ gnunet-gtk/src/plugins/fs/meta.c    2006-11-30 17:42:39 UTC (rev 3834)
@@ -318,6 +318,7 @@
                     META_VALUE, value,
                     -1);
   gtk_entry_set_text(GTK_ENTRY(entryLine), "");
+  FREENONNULL(stype);
   DEBUG_END();
 }
 
@@ -349,6 +350,7 @@
       ECRS_addToMetaData(meta,
                         type,
                         mvalue);
+      FREENONNULL(mvalue);
     } while (gtk_tree_model_iter_next(metamodel,
                                      &iter));
   }

Modified: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c       2006-11-30 16:27:35 UTC (rev 
3833)
+++ gnunet-gtk/src/plugins/fs/namespace.c       2006-11-30 17:42:39 UTC (rev 
3834)
@@ -937,9 +937,9 @@
   GtkTreeSelection * selectionNamespace;
   IUC cls;
   gint num;
-  const char * last;
-  const char * next;
-  const char * freq;
+  char * last;
+  char * next;
+  char * freq;
 
   DEBUG_BEGIN();
   contentList
@@ -1031,6 +1031,9 @@
     GE_BREAK(ectx, 0);
     UNREF(metaXML);
     metaXML = NULL;
+    FREENONNULL(last);
+    FREENONNULL(next);
+    FREENONNULL(freq);
     return;
   }
   if (OK == enc2hash(last,
@@ -1063,6 +1066,9 @@
       GE_BREAK(ectx, 0);
       UNREF(metaXML);
       metaXML = NULL;
+      FREENONNULL(last);
+      FREENONNULL(next);
+      FREENONNULL(freq);
       return;
     }
     hash2enc(&nextId,
@@ -1116,6 +1122,9 @@
         error);
       gtk_dialog_run(GTK_DIALOG(dialog));
       gtk_widget_destroy(dialog);
+      FREENONNULL(last);
+      FREENONNULL(next);
+      FREENONNULL(freq);
       return;
     }
     hash(identifierName,
@@ -1139,6 +1148,9 @@
   gtk_widget_destroy(dialog);
   UNREF(metaXML);
   metaXML = NULL;
+  FREENONNULL(last);
+  FREENONNULL(next);
+  FREENONNULL(freq);
   DEBUG_END();
 }
 
@@ -1236,6 +1248,8 @@
     gtk_widget_set_sensitive(spin,
                             FALSE);
   }
+  FREENONNULL(description);
+  FREENONNULL(encStr);
   DEBUG_END();
 }
 
@@ -1310,6 +1324,8 @@
     gtk_widget_set_sensitive(spin,
                             FALSE);
   }
+  FREENONNULL(descStr);
+  FREENONNULL(encStr);
   DEBUG_END();
 }
 

Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c  2006-11-30 16:27:35 UTC (rev 3833)
+++ gnunet-gtk/src/plugins/fs/search.c  2006-11-30 17:42:39 UTC (rev 3834)
@@ -510,8 +510,8 @@
                           "searchNamespaceComboBoxEntry");
   if (TRUE == 
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(searchNamespaceGtkCB),
                                            &iter)) {
-    const char * descStr;
-    const char * ns;
+    char * descStr;
+    char * ns;
 
     ns = NULL;
     descStr = NULL;
@@ -527,8 +527,9 @@
       ns = NULL;
     } else {
       GE_ASSERT(ectx, strlen(ns) == sizeof(EncName) - 1);
-      if (descStr == NULL)
-       descStr = ns;
+      if ( (descStr == NULL) &&
+          (ns != NULL) )
+       descStr = STRDUP(ns);
     }
     if (ns != NULL) {
       char * ustring;
@@ -550,6 +551,8 @@
       }
       FREE(ustring);
     }
+    FREENONNULL(descStr);
+    FREENONNULL(ns);
   }
   if (uri == NULL)
     uri = ECRS_parseCharKeywordURI(ectx, searchString);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]