Commit ebc6a000 authored by Kristian Rietveld's avatar Kristian Rietveld

Clean up code in gtk_tree_store_set_n_columns()

Clean up GtkTreeStore likewise as Benjamin Otte has done for
GtkListStore in commit 3c97f037.
parent 9976554c
......@@ -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;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment