From 0a8f3698a09a303f5c1ae1ae72feb095e9b1b153 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 24 Sep 2018 16:03:46 +0200 Subject: [PATCH] docs: Simplify the text for g_array_free MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The text about deallocation of GArrays with elements containing dynamically-allocated memory was confusing. It initially mentioned clear_func, but later said elements with dynamically allocated memory "should be freed separately". Clarify this by using the same structure as g_ptr_array_free — highlight the need to set a clear_func by consolidating the text about it in a separate paragraph. https://gitlab.gnome.org/GNOME/glib/merge_requests/348 --- glib/garray.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/glib/garray.c b/glib/garray.c index 488d62bb4..3ef15cd5f 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -318,15 +318,15 @@ g_array_get_element_size (GArray *array) * @free_segment: if %TRUE the actual element data is freed as well * * Frees the memory allocated for the #GArray. If @free_segment is - * %TRUE it frees the memory block holding the elements as well and - * also each element if @array has a @clear_func set. Pass %FALSE if - * you want to free the #GArray wrapper but preserve the underlying - * array for use elsewhere. If the reference count of @array is - * greater than one, the #GArray wrapper is preserved but the size of - * @array will be set to zero. + * %TRUE it frees the memory block holding the elements as well. Pass + * %FALSE if you want to free the #GArray wrapper but preserve the + * underlying array for use elsewhere. If the reference count of + * @array is greater than one, the #GArray wrapper is preserved but + * the size of @array will be set to zero. * - * If array elements contain dynamically-allocated memory, they should - * be freed separately. + * If array contents point to dynamically-allocated memory, they should + * be freed separately if @free_seg is %TRUE and no @clear_func + * function has been set for @array. * * This function is not thread-safe. If using a #GArray from multiple * threads, use only the atomic g_array_ref() and g_array_unref()