/* Returns: the new type identifier or #G_TYPE_INVALID if registration failed  */
GType g_type_register_dynamic(GType parent_type, const gchar *type_name, GTypePlugin *plugin, GTypeFlags flags)
/* Returns: the new type identifier or #G_TYPE_INVALID if registration failed  */
GType g_type_register_dynamic(GType parent_type, const gchar *type_name, GTypePlugin *plugin, GTypeFlags flags)
{
  TypeNode *pnode, *node;
  GType type;
  g_assert_type_system_initialized ();
  g_return_val_if_fail (parent_type > 0, 0);
  g_return_val_if_fail (type_name != NULL, 0);
  g_return_val_if_fail (plugin != NULL, 0);
  if (!check_type_name_I (type_name) ||
      !check_derivation_I (parent_type, type_name) ||
      !check_plugin_U (plugin, TRUE, FALSE, type_name))
    return 0;
  G_WRITE_LOCK (&type_rw_lock);
  pnode = lookup_type_node_I (parent_type);
  node = type_node_new_W (pnode, type_name, plugin);
  type_add_flags_W (node, flags);
  type = NODE_TYPE (node);
  G_WRITE_UNLOCK (&type_rw_lock);
  return type;
}