Remove redundant header inclusions

This commit is contained in:
Matthias Clasen 2010-09-03 20:15:16 -04:00
parent d95c6b8834
commit 8f81ee86ee

View File

@ -30,7 +30,8 @@
#include "config.h" #include "config.h"
#include "glib.h" #include "gslist.h"
#include "gtestutils.h"
/** /**
* SECTION: linked_lists_single * SECTION: linked_lists_single
@ -221,7 +222,7 @@ g_slist_free_1 (GSList *list)
*/ */
GSList* GSList*
g_slist_append (GSList *list, g_slist_append (GSList *list,
gpointer data) gpointer data)
{ {
GSList *new_list; GSList *new_list;
GSList *last; GSList *last;
@ -265,7 +266,7 @@ g_slist_append (GSList *list,
*/ */
GSList* GSList*
g_slist_prepend (GSList *list, g_slist_prepend (GSList *list,
gpointer data) gpointer data)
{ {
GSList *new_list; GSList *new_list;
@ -291,8 +292,8 @@ g_slist_prepend (GSList *list,
*/ */
GSList* GSList*
g_slist_insert (GSList *list, g_slist_insert (GSList *list,
gpointer data, gpointer data,
gint position) gint position)
{ {
GSList *prev_list; GSList *prev_list;
GSList *tmp_list; GSList *tmp_list;
@ -347,8 +348,8 @@ g_slist_insert (GSList *list,
*/ */
GSList* GSList*
g_slist_insert_before (GSList *slist, g_slist_insert_before (GSList *slist,
GSList *sibling, GSList *sibling,
gpointer data) gpointer data)
{ {
if (!slist) if (!slist)
{ {
@ -363,25 +364,25 @@ g_slist_insert_before (GSList *slist,
GSList *node, *last = NULL; GSList *node, *last = NULL;
for (node = slist; node; last = node, node = last->next) for (node = slist; node; last = node, node = last->next)
if (node == sibling) if (node == sibling)
break; break;
if (!last) if (!last)
{ {
node = _g_slist_alloc (); node = _g_slist_alloc ();
node->data = data; node->data = data;
node->next = slist; node->next = slist;
return node; return node;
} }
else else
{ {
node = _g_slist_alloc (); node = _g_slist_alloc ();
node->data = data; node->data = data;
node->next = last->next; node->next = last->next;
last->next = node; last->next = node;
return slist; return slist;
} }
} }
} }
@ -402,9 +403,9 @@ g_slist_concat (GSList *list1, GSList *list2)
if (list2) if (list2)
{ {
if (list1) if (list1)
g_slist_last (list1)->next = list2; g_slist_last (list1)->next = list2;
else else
list1 = list2; list1 = list2;
} }
return list1; return list1;
@ -423,7 +424,7 @@ g_slist_concat (GSList *list1, GSList *list2)
*/ */
GSList* GSList*
g_slist_remove (GSList *list, g_slist_remove (GSList *list,
gconstpointer data) gconstpointer data)
{ {
GSList *tmp, *prev = NULL; GSList *tmp, *prev = NULL;
@ -431,15 +432,15 @@ g_slist_remove (GSList *list,
while (tmp) while (tmp)
{ {
if (tmp->data == data) if (tmp->data == data)
{ {
if (prev) if (prev)
prev->next = tmp->next; prev->next = tmp->next;
else else
list = tmp->next; list = tmp->next;
g_slist_free_1 (tmp); g_slist_free_1 (tmp);
break; break;
} }
prev = tmp; prev = tmp;
tmp = prev->next; tmp = prev->next;
} }
@ -461,7 +462,7 @@ g_slist_remove (GSList *list,
*/ */
GSList* GSList*
g_slist_remove_all (GSList *list, g_slist_remove_all (GSList *list,
gconstpointer data) gconstpointer data)
{ {
GSList *tmp, *prev = NULL; GSList *tmp, *prev = NULL;
@ -469,22 +470,22 @@ g_slist_remove_all (GSList *list,
while (tmp) while (tmp)
{ {
if (tmp->data == data) if (tmp->data == data)
{ {
GSList *next = tmp->next; GSList *next = tmp->next;
if (prev) if (prev)
prev->next = next; prev->next = next;
else else
list = next; list = next;
g_slist_free_1 (tmp); g_slist_free_1 (tmp);
tmp = next; tmp = next;
} }
else else
{ {
prev = tmp; prev = tmp;
tmp = prev->next; tmp = prev->next;
} }
} }
return list; return list;
@ -492,7 +493,7 @@ g_slist_remove_all (GSList *list,
static inline GSList* static inline GSList*
_g_slist_remove_link (GSList *list, _g_slist_remove_link (GSList *list,
GSList *link) GSList *link)
{ {
GSList *tmp; GSList *tmp;
GSList *prev; GSList *prev;
@ -503,15 +504,15 @@ _g_slist_remove_link (GSList *list,
while (tmp) while (tmp)
{ {
if (tmp == link) if (tmp == link)
{ {
if (prev) if (prev)
prev->next = tmp->next; prev->next = tmp->next;
if (list == tmp) if (list == tmp)
list = list->next; list = list->next;
tmp->next = NULL; tmp->next = NULL;
break; break;
} }
prev = tmp; prev = tmp;
tmp = tmp->next; tmp = tmp->next;
@ -534,7 +535,7 @@ _g_slist_remove_link (GSList *list,
*/ */
GSList* GSList*
g_slist_remove_link (GSList *list, g_slist_remove_link (GSList *list,
GSList *link_) GSList *link_)
{ {
return _g_slist_remove_link (list, link_); return _g_slist_remove_link (list, link_);
} }
@ -552,7 +553,7 @@ g_slist_remove_link (GSList *list,
*/ */
GSList* GSList*
g_slist_delete_link (GSList *list, g_slist_delete_link (GSList *list,
GSList *link_) GSList *link_)
{ {
list = _g_slist_remove_link (list, link_); list = _g_slist_remove_link (list, link_);
_g_slist_free1 (link_); _g_slist_free1 (link_);
@ -588,12 +589,12 @@ g_slist_copy (GSList *list)
last = new_list; last = new_list;
list = list->next; list = list->next;
while (list) while (list)
{ {
last->next = _g_slist_alloc (); last->next = _g_slist_alloc ();
last = last->next; last = last->next;
last->data = list->data; last->data = list->data;
list = list->next; list = list->next;
} }
last->next = NULL; last->next = NULL;
} }
@ -638,7 +639,7 @@ g_slist_reverse (GSList *list)
*/ */
GSList* GSList*
g_slist_nth (GSList *list, g_slist_nth (GSList *list,
guint n) guint n)
{ {
while (n-- > 0 && list) while (n-- > 0 && list)
list = list->next; list = list->next;
@ -658,7 +659,7 @@ g_slist_nth (GSList *list,
*/ */
gpointer gpointer
g_slist_nth_data (GSList *list, g_slist_nth_data (GSList *list,
guint n) guint n)
{ {
while (n-- > 0 && list) while (n-- > 0 && list)
list = list->next; list = list->next;
@ -679,12 +680,12 @@ g_slist_nth_data (GSList *list,
*/ */
GSList* GSList*
g_slist_find (GSList *list, g_slist_find (GSList *list,
gconstpointer data) gconstpointer data)
{ {
while (list) while (list)
{ {
if (list->data == data) if (list->data == data)
break; break;
list = list->next; list = list->next;
} }
@ -710,15 +711,15 @@ g_slist_find (GSList *list,
*/ */
GSList* GSList*
g_slist_find_custom (GSList *list, g_slist_find_custom (GSList *list,
gconstpointer data, gconstpointer data,
GCompareFunc func) GCompareFunc func)
{ {
g_return_val_if_fail (func != NULL, list); g_return_val_if_fail (func != NULL, list);
while (list) while (list)
{ {
if (! func (list->data, data)) if (! func (list->data, data))
return list; return list;
list = list->next; list = list->next;
} }
@ -738,7 +739,7 @@ g_slist_find_custom (GSList *list,
*/ */
gint gint
g_slist_position (GSList *list, g_slist_position (GSList *list,
GSList *llink) GSList *llink)
{ {
gint i; gint i;
@ -746,7 +747,7 @@ g_slist_position (GSList *list,
while (list) while (list)
{ {
if (list == llink) if (list == llink)
return i; return i;
i++; i++;
list = list->next; list = list->next;
} }
@ -767,7 +768,7 @@ g_slist_position (GSList *list,
*/ */
gint gint
g_slist_index (GSList *list, g_slist_index (GSList *list,
gconstpointer data) gconstpointer data)
{ {
gint i; gint i;
@ -775,7 +776,7 @@ g_slist_index (GSList *list,
while (list) while (list)
{ {
if (list->data == data) if (list->data == data)
return i; return i;
i++; i++;
list = list->next; list = list->next;
} }
@ -802,7 +803,7 @@ g_slist_last (GSList *list)
if (list) if (list)
{ {
while (list->next) while (list->next)
list = list->next; list = list->next;
} }
return list; return list;
@ -846,8 +847,8 @@ g_slist_length (GSList *list)
*/ */
void void
g_slist_foreach (GSList *list, g_slist_foreach (GSList *list,
GFunc func, GFunc func,
gpointer user_data) gpointer user_data)
{ {
while (list) while (list)
{ {
@ -859,9 +860,9 @@ g_slist_foreach (GSList *list,
static GSList* static GSList*
g_slist_insert_sorted_real (GSList *list, g_slist_insert_sorted_real (GSList *list,
gpointer data, gpointer data,
GFunc func, GFunc func,
gpointer user_data) gpointer user_data)
{ {
GSList *tmp_list = list; GSList *tmp_list = list;
GSList *prev_list = NULL; GSList *prev_list = NULL;
@ -950,18 +951,18 @@ g_slist_insert_sorted (GSList *list,
*/ */
GSList* GSList*
g_slist_insert_sorted_with_data (GSList *list, g_slist_insert_sorted_with_data (GSList *list,
gpointer data, gpointer data,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data) gpointer user_data)
{ {
return g_slist_insert_sorted_real (list, data, (GFunc) func, user_data); return g_slist_insert_sorted_real (list, data, (GFunc) func, user_data);
} }
static GSList * static GSList *
g_slist_sort_merge (GSList *l1, g_slist_sort_merge (GSList *l1,
GSList *l2, GSList *l2,
GFunc compare_func, GFunc compare_func,
gpointer user_data) gpointer user_data)
{ {
GSList list, *l; GSList list, *l;
gint cmp; gint cmp;
@ -974,13 +975,13 @@ g_slist_sort_merge (GSList *l1,
if (cmp <= 0) if (cmp <= 0)
{ {
l=l->next=l1; l=l->next=l1;
l1=l1->next; l1=l1->next;
} }
else else
{ {
l=l->next=l2; l=l->next=l2;
l2=l2->next; l2=l2->next;
} }
} }
l->next= l1 ? l1 : l2; l->next= l1 ? l1 : l2;
@ -990,8 +991,8 @@ g_slist_sort_merge (GSList *l1,
static GSList * static GSList *
g_slist_sort_real (GSList *list, g_slist_sort_real (GSList *list,
GFunc compare_func, GFunc compare_func,
gpointer user_data) gpointer user_data)
{ {
GSList *l1, *l2; GSList *l1, *l2;
@ -1006,16 +1007,16 @@ g_slist_sort_real (GSList *list,
while ((l2 = l2->next) != NULL) while ((l2 = l2->next) != NULL)
{ {
if ((l2 = l2->next) == NULL) if ((l2 = l2->next) == NULL)
break; break;
l1=l1->next; l1=l1->next;
} }
l2 = l1->next; l2 = l1->next;
l1->next = NULL; l1->next = NULL;
return g_slist_sort_merge (g_slist_sort_real (list, compare_func, user_data), return g_slist_sort_merge (g_slist_sort_real (list, compare_func, user_data),
g_slist_sort_real (l2, compare_func, user_data), g_slist_sort_real (l2, compare_func, user_data),
compare_func, compare_func,
user_data); user_data);
} }
/** /**
@ -1033,7 +1034,7 @@ g_slist_sort_real (GSList *list,
*/ */
GSList * GSList *
g_slist_sort (GSList *list, g_slist_sort (GSList *list,
GCompareFunc compare_func) GCompareFunc compare_func)
{ {
return g_slist_sort_real (list, (GFunc) compare_func, NULL); return g_slist_sort_real (list, (GFunc) compare_func, NULL);
} }
@ -1050,8 +1051,8 @@ g_slist_sort (GSList *list,
*/ */
GSList * GSList *
g_slist_sort_with_data (GSList *list, g_slist_sort_with_data (GSList *list,
GCompareDataFunc compare_func, GCompareDataFunc compare_func,
gpointer user_data) gpointer user_data)
{ {
return g_slist_sort_real (list, (GFunc) compare_func, user_data); return g_slist_sort_real (list, (GFunc) compare_func, user_data);
} }