[gtk+/filesystemmodel: 1/20] clean up code in gtk_list_store_set_n_columns()
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/filesystemmodel: 1/20] clean up code in gtk_list_store_set_n_columns()
- Date: Wed, 1 Jul 2009 08:41:51 +0000 (UTC)
commit 278d1063c7d3c1a1cbde7e9cc3634214ae4ec24f
Author: Benjamin Otte <otte gnome org>
Date: Tue Jun 30 13:22:51 2009 +0200
clean up code in gtk_list_store_set_n_columns()
Previous code's messiness noted by Francisco Javier Taboada Aguado
in http://mail.gnome.org/archives/gtk-devel-list/2009-June/msg00001.html
gtk/gtkliststore.c | 20 +++++---------------
1 files changed, 5 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c
index 3f2f7c4..470c9f8 100644
--- a/gtk/gtkliststore.c
+++ b/gtk/gtkliststore.c
@@ -338,29 +338,19 @@ gtk_list_store_set_n_columns (GtkListStore *list_store,
gint n_columns)
{
GType *new_columns;
+ int i;
if (list_store->n_columns == n_columns)
return;
- new_columns = g_new0 (GType, n_columns);
- if (list_store->column_headers)
- {
- /* copy the old header orders over */
- if (n_columns >= list_store->n_columns)
- memcpy (new_columns, list_store->column_headers, list_store->n_columns * sizeof (gchar *));
- else
- memcpy (new_columns, list_store->column_headers, n_columns * sizeof (GType));
-
- g_free (list_store->column_headers);
- }
+ list_store->column_headers = g_renew (GType, list_store->column_headers, n_columns);
+ for (i = list_store->n_columns; i < n_columns; i++)
+ list_store->column_headers[i] = G_TYPE_INVALID;
+ list_store->n_columns = n_columns;
if (list_store->sort_list)
_gtk_tree_data_list_header_free (list_store->sort_list);
-
list_store->sort_list = _gtk_tree_data_list_header_new (n_columns, list_store->column_headers);
-
- list_store->column_headers = new_columns;
- list_store->n_columns = n_columns;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]