gtkarray: Create GPtrArray in insert() if we have to

This commit is contained in:
Timm Bäder 2020-05-06 10:24:15 +02:00
parent 24608d5c23
commit 75cfe3c6ae

View File

@ -88,6 +88,16 @@ gtk_array_insert (GtkArray *self,
return;
}
if (G_UNLIKELY (!self->ptr_array))
{
guint i;
self->ptr_array = g_ptr_array_new_full (self->reserved_size, NULL);
for (i = 0; i < self->len; i++)
g_ptr_array_add (self->ptr_array, self->stack_space[i]);
}
g_assert (self->ptr_array);
g_ptr_array_insert (self->ptr_array, index, element);
self->len++;