[gtk+] Clean up code in gtk_tree_store_set_n_columns()
- From: Kristian Rietveld <kristian src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Clean up code in gtk_tree_store_set_n_columns()
- Date: Sun, 23 Aug 2009 20:07:03 +0000 (UTC)
commit ebc6a000151551c843592a55029d344d03e1e17d
Author: Kristian Rietveld <kris gtk org>
Date: Sun Aug 23 15:29:11 2009 +0200
Clean up code in gtk_tree_store_set_n_columns()
Clean up GtkTreeStore likewise as Benjamin Otte has done for
GtkListStore in commit 3c97f037.
gtk/gtktreestore.c | 20 +++++---------------
1 files changed, 5 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c
index 9708408..30ff14f 100644
--- a/gtk/gtktreestore.c
+++ b/gtk/gtktreestore.c
@@ -358,30 +358,20 @@ static void
gtk_tree_store_set_n_columns (GtkTreeStore *tree_store,
gint n_columns)
{
- GType *new_columns;
+ int i;
if (tree_store->n_columns == n_columns)
return;
- new_columns = g_new0 (GType, n_columns);
- if (tree_store->column_headers)
- {
- /* copy the old header orders over */
- if (n_columns >= tree_store->n_columns)
- memcpy (new_columns, tree_store->column_headers, tree_store->n_columns * sizeof (gchar *));
- else
- memcpy (new_columns, tree_store->column_headers, n_columns * sizeof (GType));
-
- g_free (tree_store->column_headers);
- }
+ tree_store->column_headers = g_renew (GType, tree_store->column_headers, n_columns);
+ for (i = tree_store->n_columns; i < n_columns; i++)
+ tree_store->column_headers[i] = G_TYPE_INVALID;
+ tree_store->n_columns = n_columns;
if (tree_store->sort_list)
_gtk_tree_data_list_header_free (tree_store->sort_list);
tree_store->sort_list = _gtk_tree_data_list_header_new (n_columns, tree_store->column_headers);
-
- tree_store->column_headers = new_columns;
- tree_store->n_columns = n_columns;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]