Tizen 2.1 base
[platform/upstream/glib2.0.git] / glib / gslist.c
index 5dcbc7f..89e0f2d 100644 (file)
  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GLib Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/. 
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
  */
 
-/* 
+/*
  * MT safe
  */
 
 #include "config.h"
 
-#include "glib.h"
-#include "galias.h"
+#include "gslist.h"
+
+#include "gtestutils.h"
+#include "gslice.h"
 
 /**
- * SECTION: linked_lists_single
+ * SECTION:linked_lists_single
  * @title: Singly-Linked Lists
- * @short_description: linked lists containing integer values or
- *                     pointers to data, limited to iterating over the
- *                     list in one direction
+ * @short_description: linked lists that can be iterated in one direction
  *
  * The #GSList structure and its associated functions provide a
  * standard singly-linked list data structure.
@@ -47,7 +47,7 @@
  * pointer which links to the next element in the list. Using this
  * pointer it is possible to move through the list in one direction
  * only (unlike the <link
- * linkend="glib-Doubly-Linked-lists">Doubly-Linked Lists</link> which
+ * linkend="glib-Doubly-Linked-Lists">Doubly-Linked Lists</link> which
  * allow movement in both directions).
  *
  * The data contained in each element can be either integer values, by
  * A convenience macro to get the next element in a #GSList.
  **/
 
-
-/**
- * g_slist_push_allocator:
- * @dummy: the #GAllocator to use when allocating #GSList elements.
- *
- * Sets the allocator to use to allocate #GSList elements. Use
- * g_slist_pop_allocator() to restore the previous allocator.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated: 2.10: It does nothing, since #GSList has been converted
- *                   to the <link linkend="glib-Memory-Slices">slice
- *                   allocator</link>
- **/
-void g_slist_push_allocator (gpointer dummy) { /* present for binary compat only */ }
-
-/**
- * g_slist_pop_allocator:
- *
- * Restores the previous #GAllocator, used when allocating #GSList
- * elements.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated: 2.10: It does nothing, since #GSList has been converted
- *                   to the <link linkend="glib-Memory-Slices">slice
- *                   allocator</link>
- **/
-void g_slist_pop_allocator  (void)           { /* present for binary compat only */ }
-
 #define _g_slist_alloc0()       g_slice_new0 (GSList)
 #define _g_slist_alloc()        g_slice_new (GSList)
 #define _g_slist_free1(slist)   g_slice_free (GSList, slist)
@@ -159,6 +127,12 @@ g_slist_alloc (void)
  *
  * Frees all of the memory used by a #GSList.
  * The freed elements are returned to the slice allocator.
+ *
+ * <note><para>
+ * If list elements contain dynamically-allocated memory,
+ * you should either use g_slist_free_full() or free them manually
+ * first.
+ * </para></note>
  */
 void
 g_slist_free (GSList *list)
@@ -169,7 +143,7 @@ g_slist_free (GSList *list)
 /**
  * g_slist_free_1:
  * @list: a #GSList element
- * 
+ *
  * Frees one #GSList element.
  * It is usually used after g_slist_remove_link().
  */
@@ -187,6 +161,24 @@ g_slist_free_1 (GSList *list)
 }
 
 /**
+ * g_slist_free_full:
+ * @list: a pointer to a #GSList
+ * @free_func: the function to be called to free each element's data
+ *
+ * Convenience method, which frees all the memory used by a #GSList, and
+ * calls the specified destroy function on every element's data.
+ *
+ * Since: 2.28
+ **/
+void
+g_slist_free_full (GSList         *list,
+                  GDestroyNotify  free_func)
+{
+  g_slist_foreach (list, (GFunc) free_func, NULL);
+  g_slist_free (list);
+}
+
+/**
  * g_slist_append:
  * @list: a #GSList
  * @data: the data for the new element
@@ -194,14 +186,14 @@ g_slist_free_1 (GSList *list)
  * Adds a new element on to the end of the list.
  *
  * <note><para>
- * The return value is the new start of the list, which may 
+ * The return value is the new start of the list, which may
  * have changed, so make sure you store the new value.
  * </para></note>
  *
  * <note><para>
- * Note that g_slist_append() has to traverse the entire list 
- * to find the end, which is inefficient when adding multiple 
- * elements. A common idiom to avoid the inefficiency is to prepend 
+ * Note that g_slist_append() has to traverse the entire list
+ * to find the end, which is inefficient when adding multiple
+ * elements. A common idiom to avoid the inefficiency is to prepend
  * the elements and reverse the list when all elements have been added.
  * </para></note>
  *
@@ -222,7 +214,7 @@ g_slist_free_1 (GSList *list)
  */
 GSList*
 g_slist_append (GSList   *list,
-               gpointer  data)
+                gpointer  data)
 {
   GSList *new_list;
   GSList *last;
@@ -251,7 +243,7 @@ g_slist_append (GSList   *list,
  * Adds a new element on to the start of the list.
  *
  * <note><para>
- * The return value is the new start of the list, which 
+ * The return value is the new start of the list, which
  * may have changed, so make sure you store the new value.
  * </para></note>
  *
@@ -266,7 +258,7 @@ g_slist_append (GSList   *list,
  */
 GSList*
 g_slist_prepend (GSList   *list,
-                gpointer  data)
+                 gpointer  data)
 {
   GSList *new_list;
 
@@ -281,8 +273,8 @@ g_slist_prepend (GSList   *list,
  * g_slist_insert:
  * @list: a #GSList
  * @data: the data for the new element
- * @position: the position to insert the element. 
- *     If this is negative, or is larger than the number 
+ * @position: the position to insert the element.
+ *     If this is negative, or is larger than the number
  *     of elements in the list, the new element is added on
  *     to the end of the list.
  *
@@ -292,8 +284,8 @@ g_slist_prepend (GSList   *list,
  */
 GSList*
 g_slist_insert (GSList   *list,
-               gpointer  data,
-               gint      position)
+                gpointer  data,
+                gint      position)
 {
   GSList *prev_list;
   GSList *tmp_list;
@@ -322,16 +314,8 @@ g_slist_insert (GSList   *list,
       tmp_list = tmp_list->next;
     }
 
-  if (prev_list)
-    {
-      new_list->next = prev_list->next;
-      prev_list->next = new_list;
-    }
-  else
-    {
-      new_list->next = list;
-      list = new_list;
-    }
+  new_list->next = prev_list->next;
+  prev_list->next = new_list;
 
   return list;
 }
@@ -342,14 +326,14 @@ g_slist_insert (GSList   *list,
  * @sibling: node to insert @data before
  * @data: data to put in the newly-inserted node
  *
- * Inserts a node before @sibling containing @data. 
- * 
+ * Inserts a node before @sibling containing @data.
+ *
  * Returns: the new head of the list.
  */
 GSList*
 g_slist_insert_before (GSList  *slist,
-                      GSList  *sibling,
-                      gpointer data)
+                       GSList  *sibling,
+                       gpointer data)
 {
   if (!slist)
     {
@@ -364,25 +348,25 @@ g_slist_insert_before (GSList  *slist,
       GSList *node, *last = NULL;
 
       for (node = slist; node; last = node, node = last->next)
-       if (node == sibling)
-         break;
+        if (node == sibling)
+          break;
       if (!last)
-       {
-         node = _g_slist_alloc ();
-         node->data = data;
-         node->next = slist;
+        {
+          node = _g_slist_alloc ();
+          node->data = data;
+          node->next = slist;
 
-         return node;
-       }
+          return node;
+        }
       else
-       {
-         node = _g_slist_alloc ();
-         node->data = data;
-         node->next = last->next;
-         last->next = node;
-
-         return slist;
-       }
+        {
+          node = _g_slist_alloc ();
+          node->data = data;
+          node->next = last->next;
+          last->next = node;
+
+          return slist;
+        }
     }
 }
 
@@ -403,9 +387,9 @@ g_slist_concat (GSList *list1, GSList *list2)
   if (list2)
     {
       if (list1)
-       g_slist_last (list1)->next = list2;
+        g_slist_last (list1)->next = list2;
       else
-       list1 = list2;
+        list1 = list2;
     }
 
   return list1;
@@ -424,7 +408,7 @@ g_slist_concat (GSList *list1, GSList *list2)
  */
 GSList*
 g_slist_remove (GSList        *list,
-               gconstpointer  data)
+                gconstpointer  data)
 {
   GSList *tmp, *prev = NULL;
 
@@ -432,15 +416,15 @@ g_slist_remove (GSList        *list,
   while (tmp)
     {
       if (tmp->data == data)
-       {
-         if (prev)
-           prev->next = tmp->next;
-         else
-           list = tmp->next;
-
-         g_slist_free_1 (tmp);
-         break;
-       }
+        {
+          if (prev)
+            prev->next = tmp->next;
+          else
+            list = tmp->next;
+
+          g_slist_free_1 (tmp);
+          break;
+        }
       prev = tmp;
       tmp = prev->next;
     }
@@ -453,16 +437,16 @@ g_slist_remove (GSList        *list,
  * @list: a #GSList
  * @data: data to remove
  *
- * Removes all list nodes with data equal to @data. 
- * Returns the new head of the list. Contrast with 
- * g_slist_remove() which removes only the first node 
+ * Removes all list nodes with data equal to @data.
+ * Returns the new head of the list. Contrast with
+ * g_slist_remove() which removes only the first node
  * matching the given data.
  *
  * Returns: new head of @list
  */
 GSList*
 g_slist_remove_all (GSList        *list,
-                   gconstpointer  data)
+                    gconstpointer  data)
 {
   GSList *tmp, *prev = NULL;
 
@@ -470,22 +454,22 @@ g_slist_remove_all (GSList        *list,
   while (tmp)
     {
       if (tmp->data == data)
-       {
-         GSList *next = tmp->next;
-
-         if (prev)
-           prev->next = next;
-         else
-           list = next;
-         
-         g_slist_free_1 (tmp);
-         tmp = next;
-       }
+        {
+          GSList *next = tmp->next;
+
+          if (prev)
+            prev->next = next;
+          else
+            list = next;
+
+          g_slist_free_1 (tmp);
+          tmp = next;
+        }
       else
-       {
-         prev = tmp;
-         tmp = prev->next;
-       }
+        {
+          prev = tmp;
+          tmp = prev->next;
+        }
     }
 
   return list;
@@ -493,7 +477,7 @@ g_slist_remove_all (GSList        *list,
 
 static inline GSList*
 _g_slist_remove_link (GSList *list,
-                     GSList *link)
+                      GSList *link)
 {
   GSList *tmp;
   GSList *prev;
@@ -504,15 +488,15 @@ _g_slist_remove_link (GSList *list,
   while (tmp)
     {
       if (tmp == link)
-       {
-         if (prev)
-           prev->next = tmp->next;
-         if (list == tmp)
-           list = list->next;
+        {
+          if (prev)
+            prev->next = tmp->next;
+          if (list == tmp)
+            list = list->next;
 
-         tmp->next = NULL;
-         break;
-       }
+          tmp->next = NULL;
+          break;
+        }
 
       prev = tmp;
       tmp = tmp->next;
@@ -526,16 +510,16 @@ _g_slist_remove_link (GSList *list,
  * @list: a #GSList
  * @link_: an element in the #GSList
  *
- * Removes an element from a #GSList, without 
- * freeing the element. The removed element's next 
+ * Removes an element from a #GSList, without
+ * freeing the element. The removed element's next
  * link is set to %NULL, so that it becomes a
  * self-contained list with one element.
  *
  * Returns: the new start of the #GSList, without the element
  */
-GSList* 
+GSList*
 g_slist_remove_link (GSList *list,
-                    GSList *link_)
+                     GSList *link_)
 {
   return _g_slist_remove_link (list, link_);
 }
@@ -545,15 +529,15 @@ g_slist_remove_link (GSList *list,
  * @list: a #GSList
  * @link_: node to delete
  *
- * Removes the node link_ from the list and frees it. 
- * Compare this to g_slist_remove_link() which removes the node 
+ * Removes the node link_ from the list and frees it.
+ * Compare this to g_slist_remove_link() which removes the node
  * without freeing it.
  *
  * Returns: the new head of @list
  */
 GSList*
 g_slist_delete_link (GSList *list,
-                    GSList *link_)
+                     GSList *link_)
 {
   list = _g_slist_remove_link (list, link_);
   _g_slist_free1 (link_);
@@ -564,12 +548,12 @@ g_slist_delete_link (GSList *list,
 /**
  * g_slist_copy:
  * @list: a #GSList
- * 
+ *
  * Copies a #GSList.
- * 
+ *
  * <note><para>
- * Note that this is a "shallow" copy. If the list elements 
- * consist of pointers to data, the pointers are copied but 
+ * Note that this is a "shallow" copy. If the list elements
+ * consist of pointers to data, the pointers are copied but
  * the actual data isn't.
  * </para></note>
  *
@@ -589,12 +573,12 @@ g_slist_copy (GSList *list)
       last = new_list;
       list = list->next;
       while (list)
-       {
-         last->next = _g_slist_alloc ();
-         last = last->next;
-         last->data = list->data;
-         list = list->next;
-       }
+        {
+          last->next = _g_slist_alloc ();
+          last = last->next;
+          last->data = list->data;
+          list = list->next;
+        }
       last->next = NULL;
     }
 
@@ -613,17 +597,17 @@ GSList*
 g_slist_reverse (GSList *list)
 {
   GSList *prev = NULL;
-  
+
   while (list)
     {
       GSList *next = list->next;
 
       list->next = prev;
-      
+
       prev = list;
       list = next;
     }
-  
+
   return prev;
 }
 
@@ -634,12 +618,12 @@ g_slist_reverse (GSList *list)
  *
  * Gets the element at the given position in a #GSList.
  *
- * Returns: the element, or %NULL if the position is off 
+ * Returns: the element, or %NULL if the position is off
  *     the end of the #GSList
  */
 GSList*
 g_slist_nth (GSList *list,
-            guint   n)
+             guint   n)
 {
   while (n-- > 0 && list)
     list = list->next;
@@ -654,12 +638,12 @@ g_slist_nth (GSList *list,
  *
  * Gets the data of the element at the given position.
  *
- * Returns: the element's data, or %NULL if the position 
+ * Returns: the element's data, or %NULL if the position
  *     is off the end of the #GSList
  */
 gpointer
 g_slist_nth_data (GSList   *list,
-                 guint     n)
+                  guint     n)
 {
   while (n-- > 0 && list)
     list = list->next;
@@ -672,20 +656,20 @@ g_slist_nth_data (GSList   *list,
  * @list: a #GSList
  * @data: the element data to find
  *
- * Finds the element in a #GSList which 
+ * Finds the element in a #GSList which
  * contains the given data.
  *
- * Returns: the found #GSList element, 
+ * Returns: the found #GSList element,
  *     or %NULL if it is not found
  */
 GSList*
 g_slist_find (GSList        *list,
-             gconstpointer  data)
+              gconstpointer  data)
 {
   while (list)
     {
       if (list->data == data)
-       break;
+        break;
       list = list->next;
     }
 
@@ -697,29 +681,29 @@ g_slist_find (GSList        *list,
  * g_slist_find_custom:
  * @list: a #GSList
  * @data: user data passed to the function
- * @func: the function to call for each element. 
+ * @func: the function to call for each element.
  *     It should return 0 when the desired element is found
  *
- * Finds an element in a #GSList, using a supplied function to 
- * find the desired element. It iterates over the list, calling 
- * the given function which should return 0 when the desired 
- * element is found. The function takes two #gconstpointer arguments, 
- * the #GSList element's data as the first argument and the 
+ * Finds an element in a #GSList, using a supplied function to
+ * find the desired element. It iterates over the list, calling
+ * the given function which should return 0 when the desired
+ * element is found. The function takes two #gconstpointer arguments,
+ * the #GSList element's data as the first argument and the
  * given user data.
  *
  * Returns: the found #GSList element, or %NULL if it is not found
  */
 GSList*
 g_slist_find_custom (GSList        *list,
-                    gconstpointer  data,
-                    GCompareFunc   func)
+                     gconstpointer  data,
+                     GCompareFunc   func)
 {
   g_return_val_if_fail (func != NULL, list);
 
   while (list)
     {
       if (! func (list->data, data))
-       return list;
+        return list;
       list = list->next;
     }
 
@@ -731,15 +715,15 @@ g_slist_find_custom (GSList        *list,
  * @list: a #GSList
  * @llink: an element in the #GSList
  *
- * Gets the position of the given element 
+ * Gets the position of the given element
  * in the #GSList (starting from 0).
  *
- * Returns: the position of the element in the #GSList, 
+ * Returns: the position of the element in the #GSList,
  *     or -1 if the element is not found
  */
 gint
 g_slist_position (GSList *list,
-                 GSList *llink)
+                  GSList *llink)
 {
   gint i;
 
@@ -747,7 +731,7 @@ g_slist_position (GSList *list,
   while (list)
     {
       if (list == llink)
-       return i;
+        return i;
       i++;
       list = list->next;
     }
@@ -760,15 +744,15 @@ g_slist_position (GSList *list,
  * @list: a #GSList
  * @data: the data to find
  *
- * Gets the position of the element containing 
+ * Gets the position of the element containing
  * the given data (starting from 0).
  *
- * Returns: the index of the element containing the data, 
+ * Returns: the index of the element containing the data,
  *     or -1 if the data is not found
  */
 gint
 g_slist_index (GSList        *list,
-              gconstpointer  data)
+               gconstpointer  data)
 {
   gint i;
 
@@ -776,7 +760,7 @@ g_slist_index (GSList        *list,
   while (list)
     {
       if (list->data == data)
-       return i;
+        return i;
       i++;
       list = list->next;
     }
@@ -786,15 +770,15 @@ g_slist_index (GSList        *list,
 
 /**
  * g_slist_last:
- * @list: a #GSList 
+ * @list: a #GSList
  *
  * Gets the last element in a #GSList.
- *  
+ *
  * <note><para>
  * This function iterates over the whole list.
  * </para></note>
  *
- * Returns: the last element in the #GSList, 
+ * Returns: the last element in the #GSList,
  *     or %NULL if the #GSList has no elements
  */
 GSList*
@@ -803,7 +787,7 @@ g_slist_last (GSList *list)
   if (list)
     {
       while (list->next)
-       list = list->next;
+        list = list->next;
     }
 
   return list;
@@ -816,7 +800,7 @@ g_slist_last (GSList *list)
  * Gets the number of elements in a #GSList.
  *
  * <note><para>
- * This function iterates over the whole list to 
+ * This function iterates over the whole list to
  * count its elements.
  * </para></note>
  *
@@ -847,8 +831,8 @@ g_slist_length (GSList *list)
  */
 void
 g_slist_foreach (GSList   *list,
-                GFunc     func,
-                gpointer  user_data)
+                 GFunc     func,
+                 gpointer  user_data)
 {
   while (list)
     {
@@ -860,15 +844,15 @@ g_slist_foreach (GSList   *list,
 
 static GSList*
 g_slist_insert_sorted_real (GSList   *list,
-                           gpointer  data,
-                           GFunc     func,
-                           gpointer  user_data)
+                            gpointer  data,
+                            GFunc     func,
+                            gpointer  user_data)
 {
   GSList *tmp_list = list;
   GSList *prev_list = NULL;
   GSList *new_list;
   gint cmp;
+
   g_return_val_if_fail (func != NULL, list);
 
   if (!list)
@@ -878,9 +862,9 @@ g_slist_insert_sorted_real (GSList   *list,
       new_list->next = NULL;
       return new_list;
     }
+
   cmp = ((GCompareDataFunc) func) (data, tmp_list->data, user_data);
+
   while ((tmp_list->next) && (cmp > 0))
     {
       prev_list = tmp_list;
@@ -898,7 +882,7 @@ g_slist_insert_sorted_real (GSList   *list,
       new_list->next = NULL;
       return list;
     }
-  
+
   if (prev_list)
     {
       prev_list->next = new_list;
@@ -916,11 +900,11 @@ g_slist_insert_sorted_real (GSList   *list,
  * g_slist_insert_sorted:
  * @list: a #GSList
  * @data: the data for the new element
- * @func: the function to compare elements in the list. 
- *     It should return a number > 0 if the first parameter 
+ * @func: the function to compare elements in the list.
+ *     It should return a number > 0 if the first parameter
  *     comes after the second parameter in the sort order.
  *
- * Inserts a new element into the list, using the given 
+ * Inserts a new element into the list, using the given
  * comparison function to determine its position.
  *
  * Returns: the new start of the #GSList
@@ -937,12 +921,12 @@ g_slist_insert_sorted (GSList       *list,
  * g_slist_insert_sorted_with_data:
  * @list: a #GSList
  * @data: the data for the new element
- * @func: the function to compare elements in the list. 
- *     It should return a number > 0 if the first parameter 
+ * @func: the function to compare elements in the list.
+ *     It should return a number > 0 if the first parameter
  *     comes after the second parameter in the sort order.
  * @user_data: data to pass to comparison function
  *
- * Inserts a new element into the list, using the given 
+ * Inserts a new element into the list, using the given
  * comparison function to determine its position.
  *
  * Returns: the new start of the #GSList
@@ -951,18 +935,18 @@ g_slist_insert_sorted (GSList       *list,
  */
 GSList*
 g_slist_insert_sorted_with_data (GSList           *list,
-                                gpointer          data,
-                                GCompareDataFunc  func,
-                                gpointer          user_data)
+                                 gpointer          data,
+                                 GCompareDataFunc  func,
+                                 gpointer          user_data)
 {
   return g_slist_insert_sorted_real (list, data, (GFunc) func, user_data);
 }
 
 static GSList *
-g_slist_sort_merge (GSList   *l1, 
-                   GSList   *l2,
-                   GFunc     compare_func,
-                   gpointer  user_data)
+g_slist_sort_merge (GSList   *l1,
+                    GSList   *l2,
+                    GFunc     compare_func,
+                    gpointer  user_data)
 {
   GSList list, *l;
   gint cmp;
@@ -975,57 +959,57 @@ g_slist_sort_merge (GSList   *l1,
 
       if (cmp <= 0)
         {
-         l=l->next=l1;
-         l1=l1->next;
-        } 
-      else 
-       {
-         l=l->next=l2;
-         l2=l2->next;
+          l=l->next=l1;
+          l1=l1->next;
+        }
+      else
+        {
+          l=l->next=l2;
+          l2=l2->next;
         }
     }
   l->next= l1 ? l1 : l2;
-  
+
   return list.next;
 }
 
 static GSList *
 g_slist_sort_real (GSList   *list,
-                  GFunc     compare_func,
-                  gpointer  user_data)
+                   GFunc     compare_func,
+                   gpointer  user_data)
 {
   GSList *l1, *l2;
 
-  if (!list) 
+  if (!list)
     return NULL;
-  if (!list->next) 
+  if (!list->next)
     return list;
 
-  l1 = list; 
+  l1 = list;
   l2 = list->next;
 
   while ((l2 = l2->next) != NULL)
     {
-      if ((l2 = l2->next) == NULL) 
-       break;
+      if ((l2 = l2->next) == NULL)
+        break;
       l1=l1->next;
     }
-  l2 = l1->next; 
+  l2 = l1->next;
   l1->next = NULL;
 
   return g_slist_sort_merge (g_slist_sort_real (list, compare_func, user_data),
-                            g_slist_sort_real (l2, compare_func, user_data),
-                            compare_func,
-                            user_data);
+                             g_slist_sort_real (l2, compare_func, user_data),
+                             compare_func,
+                             user_data);
 }
 
 /**
  * g_slist_sort:
  * @list: a #GSList
  * @compare_func: the comparison function used to sort the #GSList.
- *     This function is passed the data from 2 elements of the #GSList 
- *     and should return 0 if they are equal, a negative value if the 
- *     first element comes before the second, or a positive value if 
+ *     This function is passed the data from 2 elements of the #GSList
+ *     and should return 0 if they are equal, a negative value if the
+ *     first element comes before the second, or a positive value if
  *     the first element comes after the second.
  *
  * Sorts a #GSList using the given comparison function.
@@ -1034,7 +1018,7 @@ g_slist_sort_real (GSList   *list,
  */
 GSList *
 g_slist_sort (GSList       *list,
-             GCompareFunc  compare_func)
+              GCompareFunc  compare_func)
 {
   return g_slist_sort_real (list, (GFunc) compare_func, NULL);
 }
@@ -1051,11 +1035,8 @@ g_slist_sort (GSList       *list,
  */
 GSList *
 g_slist_sort_with_data (GSList           *list,
-                       GCompareDataFunc  compare_func,
-                       gpointer          user_data)
+                        GCompareDataFunc  compare_func,
+                        gpointer          user_data)
 {
   return g_slist_sort_real (list, (GFunc) compare_func, user_data);
 }
-
-#define __G_SLIST_C__
-#include "galiasdef.c"