glist: Mention that g_list_length() is bad for checking list emptiness
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 2 Dec 2014 15:00:45 +0000 (15:00 +0000)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 11 Feb 2015 09:17:33 +0000 (09:17 +0000)
commit93f2998765cf2d8b0416a7d645e600b111373a76
tree940549e28e9f665e4f226a00225ec8e23b6b32df
parent926955f325e1fee48301d5a595a78a5bffd86ce5
glist: Mention that g_list_length() is bad for checking list emptiness

Despite linked lists being a fairly fundamental computer science
concept, some developers insist on using:
    g_list_length (list) > 0
to determine whether a list is non-empty, rather than using:
    list != NULL

Add a comment to the documentation for g_list_length() and
g_slist_length() pointing out the better alternative in the hope that it
will prevent some of this abuse.

https://bugzilla.gnome.org/show_bug.cgi?id=741024
glib/glist.c
glib/gslist.c