append
Adds a new element on to the end of the list.
Note that the return value is the new start of the list, if @list was empty; make sure you store the new value.
g_list_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 use g_list_prepend() and reverse the list with g_list_reverse() when all elements have been added.
|[ // Notice that these are initialized to the empty list. GList *string_list = NULL, *number_list = NULL;
// This is a list of strings. string_list = g_list_append (string_list, "first"); string_list = g_list_append (string_list, "second");
// This is a list of integers. number_list = g_list_append (number_list, GINT_TO_POINTER (27)); number_list = g_list_append (number_list, GINT_TO_POINTER (14)); ]|
Return
either @list or the new start of the #GList if @list was null
Parameters
a pointer to a #GList
the data for the new element