summaryrefslogtreecommitdiff
path: root/gtk/gtktreestore.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2009-08-23 15:29:11 +0200
committerKristian Rietveld <kris@gtk.org>2009-08-23 22:06:15 +0200
commitebc6a000151551c843592a55029d344d03e1e17d (patch)
treec8fae963be71c76d1aadf65bf94a81d8d0ec20eb /gtk/gtktreestore.c
parent9976554c6e8605aadd7d8df7fd26b3e01fc9e663 (diff)
downloadgtk+-ebc6a000151551c843592a55029d344d03e1e17d.tar.gz
Clean up code in gtk_tree_store_set_n_columns()
Clean up GtkTreeStore likewise as Benjamin Otte has done for GtkListStore in commit 3c97f037.
Diffstat (limited to 'gtk/gtktreestore.c')
-rw-r--r--gtk/gtktreestore.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c
index 97084084fb..30ff14f810 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;
}
/**