mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Call element_free_func when shrinking array with g_ptr_array_set_size
This commit is contained in:
parent
9a29f087e7
commit
bc1dd5cf11
@ -618,12 +618,8 @@ g_ptr_array_set_size (GPtrArray *farray,
|
||||
for (i = array->len; i < length; i++)
|
||||
array->pdata[i] = NULL;
|
||||
}
|
||||
if (G_UNLIKELY (g_mem_gc_friendly) && length < array->len)
|
||||
{
|
||||
int i;
|
||||
for (i = length; i < array->len; i++)
|
||||
array->pdata[i] = NULL;
|
||||
}
|
||||
else if (length < array->len)
|
||||
g_ptr_array_remove_range (farray, length, array->len - length);
|
||||
|
||||
array->len = length;
|
||||
}
|
||||
|
@ -186,9 +186,11 @@ pointer_array_free_func (void)
|
||||
g_ptr_array_add (gparray, s);
|
||||
g_assert (g_ptr_array_remove (gparray, s));
|
||||
g_assert_cmpint (num_free_func_invocations, ==, 2);
|
||||
g_ptr_array_set_size (gparray, 1);
|
||||
g_assert_cmpint (num_free_func_invocations, ==, 3);
|
||||
g_ptr_array_ref (gparray);
|
||||
g_ptr_array_unref (gparray);
|
||||
g_assert_cmpint (num_free_func_invocations, ==, 2);
|
||||
g_assert_cmpint (num_free_func_invocations, ==, 3);
|
||||
g_ptr_array_unref (gparray);
|
||||
g_assert_cmpint (num_free_func_invocations, ==, 4);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user