mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-04 06:43:07 +02:00
Fix array API inconsistency
g_array_remove_range and g_byte_array_remove_range return a pointer to the array, g_ptr_array_remove_range returns void. Since it is pretty harmless, make it return the array too. https://bugzilla.gnome.org/show_bug.cgi?id=159528
This commit is contained in:
parent
698393f15d
commit
dedc990e28
@ -1238,18 +1238,20 @@ g_ptr_array_remove_index_fast (GPtrArray *farray,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* g_ptr_array_remove_range:
|
* g_ptr_array_remove_range:
|
||||||
* @array: a @GPtrArray.
|
* @array: a @GPtrArray
|
||||||
* @index_: the index of the first pointer to remove.
|
* @index_: the index of the first pointer to remove
|
||||||
* @length: the number of pointers to remove.
|
* @length: the number of pointers to remove
|
||||||
*
|
*
|
||||||
* Removes the given number of pointers starting at the given index
|
* Removes the given number of pointers starting at the given index
|
||||||
* from a #GPtrArray. The following elements are moved to close the
|
* from a #GPtrArray. The following elements are moved to close the
|
||||||
* gap. If @array has a non-%NULL #GDestroyNotify function it is called
|
* gap. If @array has a non-%NULL #GDestroyNotify function it is called
|
||||||
* for the removed elements.
|
* for the removed elements.
|
||||||
*
|
*
|
||||||
|
* Returns: the @array
|
||||||
|
*
|
||||||
* Since: 2.4
|
* Since: 2.4
|
||||||
**/
|
**/
|
||||||
void
|
GPtrArray *
|
||||||
g_ptr_array_remove_range (GPtrArray *farray,
|
g_ptr_array_remove_range (GPtrArray *farray,
|
||||||
guint index_,
|
guint index_,
|
||||||
guint length)
|
guint length)
|
||||||
@ -1257,9 +1259,9 @@ g_ptr_array_remove_range (GPtrArray *farray,
|
|||||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||||
guint n;
|
guint n;
|
||||||
|
|
||||||
g_return_if_fail (array);
|
g_return_val_if_fail (array != NULL, NULL);
|
||||||
g_return_if_fail (index_ < array->len);
|
g_return_val_if_fail (index_ < array->len, NULL);
|
||||||
g_return_if_fail (index_ + length <= array->len);
|
g_return_val_if_fail (index_ + length <= array->len, NULL);
|
||||||
|
|
||||||
if (array->element_free_func != NULL)
|
if (array->element_free_func != NULL)
|
||||||
{
|
{
|
||||||
@ -1281,6 +1283,8 @@ g_ptr_array_remove_range (GPtrArray *farray,
|
|||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
array->pdata[array->len + i] = NULL;
|
array->pdata[array->len + i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +163,7 @@ GLIB_AVAILABLE_IN_ALL
|
|||||||
gboolean g_ptr_array_remove_fast (GPtrArray *array,
|
gboolean g_ptr_array_remove_fast (GPtrArray *array,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
void g_ptr_array_remove_range (GPtrArray *array,
|
GPtrArray *g_ptr_array_remove_range (GPtrArray *array,
|
||||||
guint index_,
|
guint index_,
|
||||||
guint length);
|
guint length);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user