Index: gtksourceundomanager.c
===================================================================
RCS file: /cvs/gnome/gtksourceview/gtksourceview/gtksourceundomanager.c,v
retrieving revision 1.10
diff -u -p -r1.10 gtksourceundomanager.c
--- gtksourceundomanager.c	25 Aug 2005 16:12:54 -0000	1.10
+++ gtksourceundomanager.c	29 Oct 2005 18:12:23 -0000
@@ -224,7 +224,6 @@ gtk_source_undo_manager_class_init (GtkS
 			      G_TYPE_NONE,
 			      1,
 			      G_TYPE_BOOLEAN);
-
 }
 
 static void
@@ -365,7 +364,6 @@ gtk_source_undo_manager_end_not_undoable
 	}
 }
 
-
 gboolean
 gtk_source_undo_manager_can_undo (const GtkSourceUndoManager *um)
 {
@@ -622,41 +620,44 @@ gtk_source_undo_manager_redo (GtkSourceU
 		um->priv->can_undo = TRUE;
 		g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, TRUE);
 	}
+}
+
+static void
+gtk_source_undo_action_free (GtkSourceUndoAction *action)
+{
+	if (action == NULL)
+		return;
+
+	if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
+		g_free (action->action.insert.text);
+	else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
+		g_free (action->action.delete.text);
+	else
+		g_return_if_reached ();
 
+	g_free (action);
 }
 
 static void 
 gtk_source_undo_manager_free_action_list (GtkSourceUndoManager *um)
 {
-	gint n, len;
-	
-	g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
-	g_return_if_fail (um->priv != NULL);
+	GList *l;
 
-	if (um->priv->actions == NULL)
-		return;
-	
-	len = g_list_length (um->priv->actions);
-	
-	for (n = 0; n < len; n++)
-	{
-		GtkSourceUndoAction *undo_action = 
-			(GtkSourceUndoAction *)(g_list_nth_data (um->priv->actions, n));
+	l = um->priv->actions;
 
-		if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
-			g_free (undo_action->action.insert.text);
-		else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
-			g_free (undo_action->action.delete.text);
-		else
-			g_return_if_fail (FALSE);
+	while (l != NULL)
+	{
+		GtkSourceUndoAction *action = l->data;
 
-		if (undo_action->order_in_group == 1)
+		if (action->order_in_group == 1)
 			--um->priv->num_of_groups;
 
-		if (undo_action->modified)
+		if (action->modified)
 			um->priv->modified_action = INVALID;
 
-		g_free (undo_action);
+		gtk_source_undo_action_free (action);
+
+		l = g_list_next (l);
 	}
 
 	g_list_free (um->priv->actions);
@@ -810,34 +811,24 @@ gtk_source_undo_manager_free_first_n_act
 					      gint 			 n)
 {
 	gint i;
-	
-	g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
-	g_return_if_fail (um->priv != NULL);
 
 	if (um->priv->actions == NULL)
 		return;
-	
+
 	for (i = 0; i < n; i++)
 	{
-		GtkSourceUndoAction *undo_action = 
-			(GtkSourceUndoAction *)(g_list_first (um->priv->actions)->data);
-	
-		if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
-			g_free (undo_action->action.insert.text);
-		else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
-			g_free (undo_action->action.delete.text);
-		else
-			g_return_if_fail (FALSE);
+		GtkSourceUndoAction *action = g_list_first (um->priv->actions)->data;
 
-		if (undo_action->order_in_group == 1)
+		if (action->order_in_group == 1)
 			--um->priv->num_of_groups;
 
-		if (undo_action->modified)
+		if (action->modified)
 			um->priv->modified_action = INVALID;
-	
-		g_free (undo_action);
 
-		um->priv->actions = g_list_delete_link (um->priv->actions, um->priv->actions);
+		gtk_source_undo_action_free (action);
+
+		um->priv->actions = g_list_delete_link (um->priv->actions,
+							um->priv->actions);
 
 		if (um->priv->actions == NULL) 
 			return;
@@ -869,20 +860,13 @@ gtk_source_undo_manager_check_list_size 
 		{
 			GList *tmp;
 			
-			if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
-				g_free (undo_action->action.insert.text);
-			else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
-				g_free (undo_action->action.delete.text);
-			else
-				g_return_if_fail (FALSE);
-
 			if (undo_action->order_in_group == 1)
 				--um->priv->num_of_groups;
 
 			if (undo_action->modified)
 				um->priv->modified_action = INVALID;
-			
-			g_free (undo_action);
+
+			gtk_source_undo_action_free (undo_action);
 
 			tmp = g_list_previous (last);
 			um->priv->actions = g_list_delete_link (um->priv->actions, last);
