Clean up code in gtk_tree_store_set_n_columns()

Clean up GtkTreeStore likewise as Benjamin Otte has done for
GtkListStore in commit 3c97f037.
This commit is contained in:
Kristian Rietveld 2009-08-23 15:29:11 +02:00
parent 9976554c6e
commit ebc6a00015

View File

@ -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;
}
/**