X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=glib%2Fglist.c;h=18e25da2d90d925ccbe777011349f56f03ad56d8;hb=aa0e8735c14ebb3cbfa38d441a6a05bb978e23b2;hp=30c0a5b5c598335bf5bd5f8b329dd511b3e0cf09;hpb=078dbda148a81af1b3a76fbda72f089b963087f1;p=platform%2Fupstream%2Fglib.git diff --git a/glib/glist.c b/glib/glist.c index 30c0a5b..18e25da 100644 --- a/glib/glist.c +++ b/glib/glist.c @@ -45,23 +45,21 @@ * Each element in the list contains a piece of data, together with * pointers which link to the previous and next elements in the list. * Using these pointers it is possible to move through the list in both - * directions (unlike the singly-linked #GSList which - * only allows movement through the list in the forward direction). + * directions (unlike the singly-linked [GSList][glib-Singly-Linked-Lists], + * which only allows movement through the list in the forward direction). * * The double linked list does not keep track of the number of items * and does not keep track of both the start and end of the list. If * you want fast access to both the start and the end of the list, * and/or the number of items in the list, use a - * GQueue instead. + * [GQueue][glib-Double-ended-Queues] instead. * * The data contained in each element can be either integer values, by - * using one of the Type - * Conversion Macros, or simply pointers to any type of data. + * using one of the [Type Conversion Macros][glib-Type-Conversion-Macros], + * or simply pointers to any type of data. * - * List elements are allocated from the slice allocator, which is more - * efficient than allocating elements individually. + * List elements are allocated from the [slice allocator][glib-Memory-Slices], + * which is more efficient than allocating elements individually. * * Note that most of the #GList functions expect to be passed a pointer * to the first element in the list. The functions which insert @@ -75,11 +73,11 @@ * g_list_insert() and g_list_insert_sorted(). * * To visit all elements in the list, use a loop over the list: - * |[ + * |[ * GList *l; * for (l = list; l != NULL; l = l->next) * { - * /* do something with l->data */ + * // do something with l->data * } * ]| * @@ -87,14 +85,14 @@ * * To loop over the list and modify it (e.g. remove a certain element) * a while loop is more appropriate, for example: - * |[ + * |[ * GList *l = list; * while (l != NULL) * { * GList *next = l->next; * if (should_be_removed (l)) * { - * /* possibly free l->data */ + * // possibly free l->data * list = g_list_delete_link (list, l); * } * l = next; @@ -118,9 +116,8 @@ /** * GList: * @data: holds the element's data, which can be a pointer to any kind - * of data, or any integer value using the Type Conversion - * Macros. + * of data, or any integer value using the + * [Type Conversion Macros][glib-Type-Conversion-Macros] * @next: contains the link to the next element in the list * @prev: contains the link to the previous element in the list * @@ -174,13 +171,10 @@ g_list_alloc (void) * @list: a #GList * * Frees all of the memory used by a #GList. - * The freed elements are returned to the slice allocator + * The freed elements are returned to the slice allocator. * - * - * If list elements contain dynamically-allocated memory, - * you should either use g_list_free_full() or free them manually - * first. - * + * If list elements contain dynamically-allocated memory, you should + * either use g_list_free_full() or free them manually first. */ void g_list_free (GList *list) @@ -239,15 +233,15 @@ g_list_free_full (GList *list, * 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. */ + * |[ + * // Notice that these are initialized to the empty list. * GList *string_list = NULL, *number_list = NULL; * - * /* This is a list of strings. */ + * // 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. */ + * // 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)); * ]| @@ -291,18 +285,16 @@ g_list_append (GList *list, * Note that the return value is the new start of the list, * which will have changed, so make sure you store the new value. * - * |[ - * /* Notice that it is initialized to the empty list. */ + * |[ + * // Notice that it is initialized to the empty list. * GList *list = NULL; * * list = g_list_prepend (list, "last"); * list = g_list_prepend (list, "first"); * ]| * - * - * Do not use this function to prepend a new element to a different element - * than the start of the list. Use g_list_insert_before() instead. - * + * Do not use this function to prepend a new element to a different + * element than the start of the list. Use g_list_insert_before() instead. * * Returns: a pointer to the newly prepended element, which is the new * start of the #GList @@ -441,7 +433,7 @@ g_list_insert_before (GList *list, * * This function is for example used to move an element in the list. * The following example moves an element to the top of the list: - * |[ + * |[ * list = g_list_remove_link (list, llink); * list = g_list_concat (llink, list); * ]| @@ -583,7 +575,7 @@ g_list_remove_all (GList *list, * This function is for example used to move an element in the list * (see the example for g_list_concat()) or to remove an element in * the list before freeing its data: - * |[ + * |[ * list = g_list_remove_link (list, llink); * free_some_data_that_may_access_the_list_again (llink->data); * g_list_free (llink); @@ -625,12 +617,10 @@ g_list_delete_link (GList *list, * * Copies a #GList. * - * * Note that this is a "shallow" copy. If the list elements * consist of pointers to data, the pointers are copied but * the actual data is not. See g_list_copy_deep() if you need * to copy the data as well. - * * * Returns: the start of the new list that holds the same data as @list */ @@ -657,12 +647,12 @@ g_list_copy (GList *list) * if the copy function takes only one argument. * * For instance, if @list holds a list of GObjects, you can do: - * |[ + * |[ * another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL); * ]| * * And, to entirely free the new list, you could do: - * |[ + * |[ * g_list_free_full (another_list, g_object_unref); * ]| * @@ -955,11 +945,9 @@ g_list_first (GList *list) * * Gets the number of elements in a #GList. * - * * This function iterates over the whole list to count its elements. - * Use a GQueue instead - * of a GList if you regularly need the number of items. - * + * Use a #GQueue instead of a GList if you regularly need the number + * of items. * * Returns: the number of elements in the #GList */ @@ -1071,12 +1059,10 @@ g_list_insert_sorted_real (GList *list, * Inserts a new element into the list, using the given comparison * function to determine its position. * - * * If you are adding many new elements to a list, and the number of * new elements is much larger than the length of the list, use * g_list_prepend() to add the new items and sort the list afterwards - * with g_list_sort() - * + * with g_list_sort(). * * Returns: the (possibly changed) start of the #GList */ @@ -1101,12 +1087,10 @@ g_list_insert_sorted (GList *list, * Inserts a new element into the list, using the given comparison * function to determine its position. * - * * If you are adding many new elements to a list, and the number of * new elements is much larger than the length of the list, use * g_list_prepend() to add the new items and sort the list afterwards - * with g_list_sort() - * + * with g_list_sort(). * * Returns: the (possibly changed) start of the #GList * @@ -1211,7 +1195,7 @@ g_list_sort_real (GList *list, * value comes before the second, 0 if they are equal, or a positive * integer if the first value comes after the second. * - * Returns: negative value if @a < @b; zero if @a = @b; positive + * Returns: negative value if @a < @b; zero if @a = @b; positive * value if @a > @b */ GList * @@ -1243,7 +1227,7 @@ g_list_sort (GList *list, * value comes before the second, 0 if they are equal, or a positive * integer if the first value comes after the second. * - * Returns: negative value if @a < @b; zero if @a = @b; positive + * Returns: negative value if @a < @b; zero if @a = @b; positive * value if @a > @b */ GList *