/* Sets the size of the array. When making the array larger, newly-added elements will be set to NULL. When making it smaller, if @array has a non-NULL #GDestroyNotify function then it will be called for the removed elements.  */
void g_ptr_array_set_size(GPtrArray *array, gint length)
/* Sets the size of the array. When making the array larger, newly-added elements will be set to NULL. When making it smaller, if @array has a non-NULL #GDestroyNotify function then it will be called for the removed elements.  */
void g_ptr_array_set_size(GPtrArray *array, gint length)
{
  GRealPtrArray *rarray = (GRealPtrArray *)array;
  g_return_if_fail (rarray);
  if (length > rarray->len)
    {
      int i;
      g_ptr_array_maybe_expand (rarray, (length - rarray->len));
      for (i = rarray->len; i < length; i++)
        rarray->pdata[i] = NULL;
    }
  else if (length < rarray->len)
    g_ptr_array_remove_range (array, length, rarray->len - length);
  rarray->len = length;
}