/* Returns: (array length=n_children) (transfer full): Newly allocated and 0-terminated array of child types, free with g_free()  */
GType* g_type_children(GType type, guint *n_children)
/* Returns: (array length=n_children) (transfer full): Newly allocated and 0-terminated array of child types, free with g_free()  */
GType* g_type_children(GType type, guint *n_children)
{
  TypeNode *node;
  node = lookup_type_node_I (type);
  if (node)
    {
      GType *children;
      G_READ_LOCK (&type_rw_lock);
      children = g_new (GType, node->n_children + 1);
      memcpy (children, node->children, sizeof (GType) * node->n_children);
      children[node->n_children] = 0;
      if (n_children)
	*n_children = node->n_children;
      G_READ_UNLOCK (&type_rw_lock);
      return children;
    }
  else
    {
      if (n_children)
	*n_children = 0;
      return NULL;
    }
}