]> Pileus Git - ~andy/gtk/blobdiff - tests/testtreemodel.c
tests: fix testtreecolumns not to segfault at startup
[~andy/gtk] / tests / testtreemodel.c
index fd01d70987f7c04a9acc6898a759cdb398f79020..0c228ea40771b3fcf246a0a939c7167af16854a4 100644 (file)
@@ -1,4 +1,28 @@
+/* testtreemodel.c
+ * Copyright (C) 2004  Red Hat, Inc.,  Matthias Clasen <mclasen@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#ifdef HAVE_MALLINFO
 #include <malloc.h>
+#endif
+
 #include <gtk/gtk.h>
 
 static gint repeats = 2;
@@ -166,7 +190,6 @@ tree_store_insert_deep (GtkTreeModel *model,
   GtkTreeIter iter;
   gchar *text;
   FindData data;
-  gint n;
 
   text = g_strdup_printf ("row %d", i);
   data.n = g_random_int_range (0, items);
@@ -174,7 +197,7 @@ tree_store_insert_deep (GtkTreeModel *model,
   data.found = FALSE;
   if (data.n < i)
     gtk_tree_model_foreach (model, find_nth, &data);
-  gtk_tree_store_insert (store, &iter, data.found ? &(data.iter) : NULL, n);
+  gtk_tree_store_insert (store, &iter, data.found ? &(data.iter) : NULL, data.n);
   gtk_tree_store_set (store, &iter, 0, i, 1, text, -1);
   g_free (text);
 }
@@ -186,12 +209,10 @@ test_run (gchar        *title,
          ClearFunc    *clear,
          InsertFunc   *insert)
 {
-  GtkTreeIter iter;
   gint i, k, d, items;
-  gchar *text;
   GTimer *timer;
   gdouble elapsed;
-  int uordblks_before, memused;
+  int uordblks_before = 0, memused;
 
   g_print ("%s (average over %d runs, time in milliseconds)\n"
           "items \ttime      \ttime/item \tused memory\n", title, repeats);
@@ -232,7 +253,6 @@ int
 main (int argc, char *argv[])
 {
   GtkTreeModel *model;
-  GOptionContext *context;
   
   gtk_init_with_args (&argc, &argv, NULL, entries, NULL, NULL);