gnunet-svn
[Top][All Lists]
Advanced

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

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


From: grothoff
Subject: [GNUnet-SVN] r3835 - in gnunet-gtk/src: common include plugins/fs
Date: Thu, 30 Nov 2006 10:14:52 -0800 (PST)

Author: grothoff
Date: 2006-11-30 10:14:48 -0800 (Thu, 30 Nov 2006)
New Revision: 3835

Modified:
   gnunet-gtk/src/common/iterators.c
   gnunet-gtk/src/include/gnunetgtk_common.h
   gnunet-gtk/src/plugins/fs/download.c
   gnunet-gtk/src/plugins/fs/namespace.c
   gnunet-gtk/src/plugins/fs/search.c
Log:
fixes

Modified: gnunet-gtk/src/common/iterators.c
===================================================================
--- gnunet-gtk/src/common/iterators.c   2006-11-30 17:42:39 UTC (rev 3834)
+++ gnunet-gtk/src/common/iterators.c   2006-11-30 18:14:48 UTC (rev 3835)
@@ -27,6 +27,7 @@
 #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
@@ -75,3 +76,62 @@
        size,
        0);
 }
+
+typedef struct {
+  GtkTreeRowReference ** refs;
+  unsigned int pos;
+  unsigned int size;
+} CollectData;
+
+static gboolean
+collectAllRows(GtkTreeModel * model,
+              GtkTreePath * path,
+              GtkTreeIter * iter,
+              gpointer cls) {
+  CollectData * cd = cls;
+
+  if (cd->size == cd->pos)
+    GROW(cd->refs,
+        cd->size,
+        cd->size * 2 + 4);
+  cd->refs[cd->pos++] = gtk_tree_row_reference_new(model,
+                                                  path);
+  return FALSE;
+}
+              
+
+/**
+ * Identical to "gtk_tree_model_foreach",
+ * except that modifications of the underlying model
+ * during the iteration are tolerated.
+ */
+void ggc_tree_model_foreach(GtkTreeModel * model,
+                           GtkTreeSelectionForeachFunc func,
+                           gpointer data) {
+  unsigned int i;
+  GtkTreePath * path;
+  GtkTreeIter iter;
+  CollectData cd;
+
+  memset(&cd,
+        0,
+        sizeof(CollectData));
+  gtk_tree_model_foreach(model,
+                        &collectAllRows,
+                        &cd);
+  for (i=0;i<cd.pos;i++) {
+    path = gtk_tree_row_reference_get_path(cd.refs[i]);
+    gtk_tree_row_reference_free(cd.refs[i]);
+    if (TRUE == gtk_tree_model_get_iter(model,
+                                       &iter,
+                                       path))
+      func(model,
+          path,
+          &iter,
+          data);
+    gtk_tree_path_free(path);
+  }
+  GROW(cd.refs,
+       cd.size,
+       0);
+}

Modified: gnunet-gtk/src/include/gnunetgtk_common.h
===================================================================
--- gnunet-gtk/src/include/gnunetgtk_common.h   2006-11-30 17:42:39 UTC (rev 
3834)
+++ gnunet-gtk/src/include/gnunetgtk_common.h   2006-11-30 18:14:48 UTC (rev 
3835)
@@ -151,4 +151,13 @@
                                         GtkTreeSelectionForeachFunc func,
                                         gpointer data);
 
+/**
+ * Identical to "gtk_tree_model_foreach",
+ * except that modifications of the underlying model
+ * during the iteration are tolerated.
+ */
+void ggc_tree_model_foreach(GtkTreeModel * model,
+                           GtkTreeSelectionForeachFunc func,
+                           gpointer data);
+
 #endif

Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c        2006-11-30 17:42:39 UTC (rev 
3834)
+++ gnunet-gtk/src/plugins/fs/download.c        2006-11-30 18:14:48 UTC (rev 
3835)
@@ -409,10 +409,11 @@
                         -1);
       if ( (name != NULL) &&
           (0 == strcmp(name, filename)) ) {
-       FREE(name);
+       free(name);
        return SYSERR;
       }
-      FREENONNULL(name);
+      if (name != NULL)
+       free(name);
       if (SYSERR == check_pending(filename,
                                  &iter))
        return SYSERR;
@@ -533,7 +534,7 @@
   dirPath[0] = '\0';
   dirPathLen = 0;
   while (gtk_tree_path_get_depth(dirTreePath) > 1) {
-    const char * dirname;
+    char * dirname;
     char * new;
 
     if (! gtk_tree_path_up(dirTreePath))
@@ -555,6 +556,7 @@
     strcat(new, dirPath);
     FREE(dirPath);
     dirPath = new;
+    free(dirname);
   }
   gtk_tree_path_free(dirTreePath);
 
@@ -733,7 +735,7 @@
 
 void on_clearCompletedDownloadsButton_clicked_fs(void * unused,
                                                 GtkWidget * clearButton) {
-  gtk_tree_model_foreach(GTK_TREE_MODEL(download_summary),
+  ggc_tree_model_foreach(GTK_TREE_MODEL(download_summary),
                         &clearCompletedDownloadCallback,
                         NULL);
 }

Modified: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c       2006-11-30 17:42:39 UTC (rev 
3834)
+++ gnunet-gtk/src/plugins/fs/namespace.c       2006-11-30 18:14:48 UTC (rev 
3835)
@@ -1031,9 +1031,12 @@
     GE_BREAK(ectx, 0);
     UNREF(metaXML);
     metaXML = NULL;
-    FREENONNULL(last);
-    FREENONNULL(next);
-    FREENONNULL(freq);
+    if (last != NULL)
+      free(last);
+    if (next != NULL)
+      free(next);
+    if (freq != NULL)
+      free(freq);
     return;
   }
   if (OK == enc2hash(last,
@@ -1066,9 +1069,12 @@
       GE_BREAK(ectx, 0);
       UNREF(metaXML);
       metaXML = NULL;
-      FREENONNULL(last);
-      FREENONNULL(next);
-      FREENONNULL(freq);
+      if (last != NULL)
+       free(last);
+      if (next != NULL)
+       free(next);
+      if (freq != NULL)
+       free(freq);
       return;
     }
     hash2enc(&nextId,
@@ -1148,9 +1154,12 @@
   gtk_widget_destroy(dialog);
   UNREF(metaXML);
   metaXML = NULL;
-  FREENONNULL(last);
-  FREENONNULL(next);
-  FREENONNULL(freq);
+  if (last != NULL)
+    free(last);
+  if (next != NULL)
+    free(next);
+  if (freq != NULL)
+    free(freq);
   DEBUG_END();
 }
 
@@ -1248,8 +1257,10 @@
     gtk_widget_set_sensitive(spin,
                             FALSE);
   }
-  FREENONNULL(description);
-  FREENONNULL(encStr);
+  if (description != NULL)
+    free(description);
+  if (encStr != NULL)
+    free(encStr);
   DEBUG_END();
 }
 
@@ -1324,8 +1335,10 @@
     gtk_widget_set_sensitive(spin,
                             FALSE);
   }
-  FREENONNULL(descStr);
-  FREENONNULL(encStr);
+  if (descStr != NULL)
+    free(descStr);
+  if (encStr != NULL)
+    free(encStr);
   DEBUG_END();
 }
 

Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c  2006-11-30 17:42:39 UTC (rev 3834)
+++ gnunet-gtk/src/plugins/fs/search.c  2006-11-30 18:14:48 UTC (rev 3835)
@@ -551,8 +551,10 @@
       }
       FREE(ustring);
     }
-    FREENONNULL(descStr);
-    FREENONNULL(ns);
+    if (descStr != NULL)
+      free(descStr);
+    if (ns != NULL)
+      free(ns);
   }
   if (uri == NULL)
     uri = ECRS_parseCharKeywordURI(ectx, searchString);





reply via email to

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