GNOME Bugzilla – Bug 741024
glist: Mention that g_list_length() is bad for checking list emptiness
Last modified: 2015-02-11 09:17:55 UTC
Minor docs addition in response to persistent problems I’ve seen in some code I’ve been reviewing.
Created attachment 291994 [details] [review] 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.
Review of attachment 291994 [details] [review]: Docs here are pretty simple, so no harm done by this.
Attachment 291994 [details] pushed as 93f2998 - glist: Mention that g_list_length() is bad for checking list emptiness