mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
glist: code style cleanup for g_list_insert_before()
This makes the g_list_insert_before() follow more closely the guidelines for GLib, which is to avoid implicit pointer boolean value and to prefer for over while to improve readability.
This commit is contained in:
parent
a4c3feb835
commit
b3925ff5e4
10
glib/glist.c
10
glib/glist.c
@ -441,14 +441,14 @@ g_list_insert_before (GList *list,
|
|||||||
GList *sibling,
|
GList *sibling,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (list == NULL)
|
||||||
{
|
{
|
||||||
list = g_list_alloc ();
|
list = g_list_alloc ();
|
||||||
list->data = data;
|
list->data = data;
|
||||||
g_return_val_if_fail (sibling == NULL, list);
|
g_return_val_if_fail (sibling == NULL, list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
else if (sibling)
|
else if (sibling != NULL)
|
||||||
{
|
{
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ g_list_insert_before (GList *list,
|
|||||||
node->prev = sibling->prev;
|
node->prev = sibling->prev;
|
||||||
node->next = sibling;
|
node->next = sibling;
|
||||||
sibling->prev = node;
|
sibling->prev = node;
|
||||||
if (node->prev)
|
if (node->prev != NULL)
|
||||||
{
|
{
|
||||||
node->prev->next = node;
|
node->prev->next = node;
|
||||||
return list;
|
return list;
|
||||||
@ -472,9 +472,7 @@ g_list_insert_before (GList *list,
|
|||||||
{
|
{
|
||||||
GList *last;
|
GList *last;
|
||||||
|
|
||||||
last = list;
|
for (last = list; last->next != NULL; last = last->next) {}
|
||||||
while (last->next)
|
|
||||||
last = last->next;
|
|
||||||
|
|
||||||
last->next = _g_list_alloc ();
|
last->next = _g_list_alloc ();
|
||||||
last->next->data = data;
|
last->next->data = data;
|
||||||
|
Loading…
Reference in New Issue
Block a user