/* metainfo-loader.c generated by valac 0.56.19, the Vala compiler
 * generated from metainfo-loader.vala, do not modify */

#include "protonplus_core.h"
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <appstream.h>
#include <gee.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	PROTON_PLUS_UTILS_INTERNAL_META_INFO_LOADER_0_PROPERTY,
	PROTON_PLUS_UTILS_INTERNAL_META_INFO_LOADER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_internal_meta_info_loader_properties[PROTON_PLUS_UTILS_INTERNAL_META_INFO_LOADER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _ProtonPlusUtilsInternalMetaInfoLoaderPrivate {
	ProtonPlusModelsInternalMetaInfo* model;
};

static gint ProtonPlusUtilsInternalMetaInfoLoader_private_offset;
static gpointer proton_plus_utils_internal_meta_info_loader_parent_class = NULL;

static GFile* proton_plus_utils_internal_meta_info_loader_get_metafile (ProtonPlusUtilsInternalMetaInfoLoader* self);
static gchar* proton_plus_utils_internal_meta_info_loader_normalize_release_date (ProtonPlusUtilsInternalMetaInfoLoader* self,
                                                                           const gchar* raw_date);
static void proton_plus_utils_internal_meta_info_loader_finalize (GObject * obj);
static GType proton_plus_utils_internal_meta_info_loader_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
proton_plus_utils_internal_meta_info_loader_get_instance_private (ProtonPlusUtilsInternalMetaInfoLoader* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusUtilsInternalMetaInfoLoader_private_offset);
}

ProtonPlusUtilsInternalMetaInfoLoader*
proton_plus_utils_internal_meta_info_loader_construct (GType object_type)
{
	ProtonPlusUtilsInternalMetaInfoLoader * self = NULL;
	self = (ProtonPlusUtilsInternalMetaInfoLoader*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusUtilsInternalMetaInfoLoader*
proton_plus_utils_internal_meta_info_loader_new (void)
{
	return proton_plus_utils_internal_meta_info_loader_construct (PROTON_PLUS_UTILS_INTERNAL_TYPE_META_INFO_LOADER);
}

static GFile*
proton_plus_utils_internal_meta_info_loader_get_metafile (ProtonPlusUtilsInternalMetaInfoLoader* self)
{
	gchar** files = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gint files_length1;
	gint _files_size_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	GFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("/usr/share/metainfo/com.vysp3r.ProtonPlus.metainfo.xml");
	_tmp1_ = g_strdup ("data/com.vysp3r.ProtonPlus.metainfo.xml");
	_tmp2_ = g_strdup ("../data/com.vysp3r.ProtonPlus.metainfo.xml");
	_tmp3_ = g_strdup ("/usr/share/metainfo/com.vysp3r.ProtonPlus.metainfo.xml.in");
	_tmp4_ = g_strdup ("data/com.vysp3r.ProtonPlus.metainfo.xml.in");
	_tmp5_ = g_strdup ("../data/com.vysp3r.ProtonPlus.metainfo.xml.in");
	_tmp6_ = g_new0 (gchar*, 6 + 1);
	_tmp6_[0] = _tmp0_;
	_tmp6_[1] = _tmp1_;
	_tmp6_[2] = _tmp2_;
	_tmp6_[3] = _tmp3_;
	_tmp6_[4] = _tmp4_;
	_tmp6_[5] = _tmp5_;
	files = _tmp6_;
	files_length1 = 6;
	_files_size_ = files_length1;
	_tmp7_ = files;
	_tmp7__length1 = files_length1;
	{
		gchar** item_collection = NULL;
		gint item_collection_length1 = 0;
		gint _item_collection_size_ = 0;
		gint item_it = 0;
		item_collection = _tmp7_;
		item_collection_length1 = _tmp7__length1;
		for (item_it = 0; item_it < item_collection_length1; item_it = item_it + 1) {
			gchar* _tmp8_;
			gchar* item = NULL;
			_tmp8_ = g_strdup (item_collection[item_it]);
			item = _tmp8_;
			{
				GFile* file = NULL;
				const gchar* _tmp9_;
				GFile* _tmp10_;
				GFile* _tmp11_;
				_tmp9_ = item;
				_tmp10_ = g_file_new_for_path (_tmp9_);
				file = _tmp10_;
				_tmp11_ = file;
				if (g_file_query_exists (_tmp11_, NULL)) {
					result = file;
					_g_free0 (item);
					files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_free), NULL);
					return result;
				}
				_g_object_unref0 (file);
				_g_free0 (item);
			}
		}
	}
	g_warning ("metainfo-loader.vala:27: Metainfo file not found!");
	result = NULL;
	files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

static gboolean
int64_try_parse (const gchar* str,
                 gint64* _result_,
                 const gchar** unparsed,
                 guint _base)
{
	gint64 _vala__result_ = 0LL;
	const gchar* _vala_unparsed = NULL;
	gchar* endptr = NULL;
	gchar* _tmp0_ = NULL;
	gint64 _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean result;
	g_return_val_if_fail (str != NULL, FALSE);
	errno = 0;
	_tmp1_ = g_ascii_strtoll (str, &_tmp0_, _base);
	endptr = _tmp0_;
	_vala__result_ = _tmp1_;
	_tmp2_ = endptr;
	_tmp3_ = strlen (str);
	_tmp4_ = _tmp3_;
	if (_tmp2_ == (((gchar*) str) + _tmp4_)) {
		gboolean _tmp5_ = FALSE;
		_vala_unparsed = "";
		if (errno != ERANGE) {
			_tmp5_ = errno != EINVAL;
		} else {
			_tmp5_ = FALSE;
		}
		result = _tmp5_;
		if (_result_) {
			*_result_ = _vala__result_;
		}
		if (unparsed) {
			*unparsed = _vala_unparsed;
		}
		return result;
	} else {
		gchar* _tmp6_;
		_tmp6_ = endptr;
		_vala_unparsed = (const gchar*) _tmp6_;
		result = FALSE;
		if (_result_) {
			*_result_ = _vala__result_;
		}
		if (unparsed) {
			*unparsed = _vala_unparsed;
		}
		return result;
	}
}

static gchar*
proton_plus_utils_internal_meta_info_loader_normalize_release_date (ProtonPlusUtilsInternalMetaInfoLoader* self,
                                                                    const gchar* raw_date)
{
	gboolean _tmp0_ = FALSE;
	GDateTime* iso_date = NULL;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	gint64 unix_timestamp = 0LL;
	gint64 _tmp5_ = 0LL;
	gboolean _tmp6_;
	gchar* _tmp11_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (raw_date == NULL) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (raw_date, "") == 0;
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp1_ = g_date_time_new_from_iso8601 (raw_date, NULL);
	iso_date = _tmp1_;
	_tmp2_ = iso_date;
	if (_tmp2_ != NULL) {
		GDateTime* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = iso_date;
		_tmp4_ = g_date_time_format (_tmp3_, "%Y-%m-%d");
		result = _tmp4_;
		_g_date_time_unref0 (iso_date);
		return result;
	}
	unix_timestamp = (gint64) 0;
	_tmp6_ = int64_try_parse (raw_date, &_tmp5_, NULL, (guint) 0);
	unix_timestamp = _tmp5_;
	if (_tmp6_) {
		GDateTime* unix_date = NULL;
		GDateTime* _tmp7_;
		GDateTime* _tmp8_;
		_tmp7_ = g_date_time_new_from_unix_local (unix_timestamp);
		unix_date = _tmp7_;
		_tmp8_ = unix_date;
		if (_tmp8_ != NULL) {
			GDateTime* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = unix_date;
			_tmp10_ = g_date_time_format (_tmp9_, "%Y-%m-%d");
			result = _tmp10_;
			_g_date_time_unref0 (unix_date);
			_g_date_time_unref0 (iso_date);
			return result;
		}
		_g_date_time_unref0 (unix_date);
	}
	_tmp11_ = g_strdup (raw_date);
	result = _tmp11_;
	_g_date_time_unref0 (iso_date);
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

ProtonPlusModelsInternalMetaInfo*
proton_plus_utils_internal_meta_info_loader_load (ProtonPlusUtilsInternalMetaInfoLoader* self)
{
	AsMetadata* mdata = NULL;
	AsMetadata* _tmp0_;
	GError* _inner_error0_ = NULL;
	ProtonPlusModelsInternalMetaInfo* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = as_metadata_new ();
	mdata = _tmp0_;
	{
		GFile* resource_file = NULL;
		GFile* _tmp1_;
		GFile* _tmp2_;
		AsComponent* component = NULL;
		AsMetadata* _tmp9_;
		AsComponent* _tmp10_;
		AsComponent* _tmp11_;
		AsComponent* _tmp12_;
		ProtonPlusModelsInternalMetaInfo* _tmp13_;
		ProtonPlusModelsInternalMetaInfo* _tmp14_;
		AsComponent* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		ProtonPlusModelsInternalMetaInfo* _tmp19_;
		AsComponent* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		ProtonPlusModelsInternalMetaInfo* _tmp23_;
		AsComponent* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		ProtonPlusModelsInternalMetaInfo* _tmp27_;
		AsComponent* _tmp28_;
		const gchar* _tmp29_;
		gchar* _tmp30_;
		ProtonPlusModelsInternalMetaInfo* _tmp31_;
		AsComponent* _tmp32_;
		const gchar* _tmp33_;
		const gchar* _tmp34_;
		gchar* _tmp35_;
		AsReleaseList* releases = NULL;
		AsComponent* _tmp36_;
		AsReleaseList* _tmp37_;
		AsReleaseList* _tmp38_;
		AsReleaseList* _tmp39_;
		GPtrArray* _tmp40_;
		ProtonPlusModelsInternalMetaInfo* _tmp68_;
		ProtonPlusModelsInternalMetaInfo* _tmp69_;
		_tmp1_ = g_file_new_for_uri ("resource:///com/vysp3r/ProtonPlus/metainfo.xml");
		resource_file = _tmp1_;
		_tmp2_ = resource_file;
		if (g_file_query_exists (_tmp2_, NULL)) {
			AsMetadata* _tmp3_;
			GFile* _tmp4_;
			_tmp3_ = mdata;
			_tmp4_ = resource_file;
			as_metadata_parse_file (_tmp3_, _tmp4_, AS_FORMAT_KIND_XML, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (resource_file);
				goto __catch0_g_error;
			}
		} else {
			GFile* file = NULL;
			GFile* _tmp5_;
			GFile* _tmp6_;
			AsMetadata* _tmp7_;
			GFile* _tmp8_;
			_tmp5_ = proton_plus_utils_internal_meta_info_loader_get_metafile (self);
			file = _tmp5_;
			_tmp6_ = file;
			if (_tmp6_ == NULL) {
				result = NULL;
				_g_object_unref0 (file);
				_g_object_unref0 (resource_file);
				_g_object_unref0 (mdata);
				return result;
			}
			_tmp7_ = mdata;
			_tmp8_ = file;
			as_metadata_parse_file (_tmp7_, _tmp8_, AS_FORMAT_KIND_XML, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (file);
				_g_object_unref0 (resource_file);
				goto __catch0_g_error;
			}
			_g_object_unref0 (file);
		}
		_tmp9_ = mdata;
		_tmp10_ = as_metadata_get_component (_tmp9_);
		_tmp11_ = _g_object_ref0 (_tmp10_);
		component = _tmp11_;
		_tmp12_ = component;
		if (_tmp12_ == NULL) {
			result = NULL;
			_g_object_unref0 (component);
			_g_object_unref0 (resource_file);
			_g_object_unref0 (mdata);
			return result;
		}
		_tmp13_ = proton_plus_models_internal_meta_info_new ();
		_g_object_unref0 (self->priv->model);
		self->priv->model = _tmp13_;
		_tmp14_ = self->priv->model;
		_tmp15_ = component;
		_tmp16_ = as_component_get_id (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = g_strdup (_tmp17_);
		_g_free0 (_tmp14_->id);
		_tmp14_->id = _tmp18_;
		_tmp19_ = self->priv->model;
		_tmp20_ = component;
		g_object_get (_tmp20_, "name", &_tmp21_, NULL);
		_tmp22_ = _tmp21_;
		_g_free0 (_tmp19_->name);
		_tmp19_->name = _tmp22_;
		_tmp23_ = self->priv->model;
		_tmp24_ = component;
		g_object_get (_tmp24_, "summary", &_tmp25_, NULL);
		_tmp26_ = _tmp25_;
		_g_free0 (_tmp23_->summary);
		_tmp23_->summary = _tmp26_;
		_tmp27_ = self->priv->model;
		_tmp28_ = component;
		_tmp29_ = as_component_get_metadata_license (_tmp28_);
		_tmp30_ = g_strdup (_tmp29_);
		_g_free0 (_tmp27_->metadata_license);
		_tmp27_->metadata_license = _tmp30_;
		_tmp31_ = self->priv->model;
		_tmp32_ = component;
		_tmp33_ = as_component_get_project_license (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = g_strdup (_tmp34_);
		_g_free0 (_tmp31_->project_license);
		_tmp31_->project_license = _tmp35_;
		_tmp36_ = component;
		_tmp37_ = as_component_get_releases_plain (_tmp36_);
		_tmp38_ = _g_object_ref0 (_tmp37_);
		releases = _tmp38_;
		_tmp39_ = releases;
		_tmp40_ = as_release_list_get_entries (_tmp39_);
		{
			GPtrArray* rel_collection = NULL;
			guint rel_index = 0U;
			rel_collection = _tmp40_;
			for (rel_index = 0; rel_index < rel_collection->len; rel_index = rel_index + 1) {
				AsRelease* _tmp41_;
				AsRelease* rel = NULL;
				_tmp41_ = _g_object_ref0 ((AsRelease*) g_ptr_array_index (rel_collection, rel_index));
				rel = _tmp41_;
				{
					AsRelease* _tmp42_;
					gchar* version = NULL;
					AsRelease* _tmp43_;
					const gchar* _tmp44_;
					gchar* _tmp45_;
					gchar* date_timestamp = NULL;
					AsRelease* _tmp46_;
					const gchar* _tmp47_;
					gchar* _tmp48_;
					gchar* date_str = NULL;
					const gchar* _tmp49_;
					gchar* _tmp50_;
					const gchar* _tmp51_ = NULL;
					AsRelease* _tmp52_;
					const gchar* _tmp53_;
					gchar* description = NULL;
					gchar* _tmp54_;
					ProtonPlusModelsInternalMetaInfoRelease* release = NULL;
					ProtonPlusModelsInternalMetaInfoRelease* _tmp55_;
					ProtonPlusModelsInternalMetaInfoRelease* _tmp56_;
					const gchar* _tmp57_;
					gchar* _tmp58_;
					ProtonPlusModelsInternalMetaInfoRelease* _tmp59_;
					const gchar* _tmp60_;
					gchar* _tmp61_;
					ProtonPlusModelsInternalMetaInfoRelease* _tmp62_;
					const gchar* _tmp63_;
					gchar* _tmp64_;
					ProtonPlusModelsInternalMetaInfo* _tmp65_;
					GeeList* _tmp66_;
					ProtonPlusModelsInternalMetaInfoRelease* _tmp67_;
					_tmp42_ = rel;
					if (_tmp42_ == NULL) {
						_g_object_unref0 (rel);
						continue;
					}
					_tmp43_ = rel;
					_tmp44_ = as_release_get_version (_tmp43_);
					_tmp45_ = g_strdup (_tmp44_);
					version = _tmp45_;
					_tmp46_ = rel;
					_tmp47_ = as_release_get_date (_tmp46_);
					_tmp48_ = g_strdup (_tmp47_);
					date_timestamp = _tmp48_;
					_tmp49_ = date_timestamp;
					_tmp50_ = proton_plus_utils_internal_meta_info_loader_normalize_release_date (self, _tmp49_);
					date_str = _tmp50_;
					_tmp52_ = rel;
					_tmp53_ = as_release_get_description (_tmp52_);
					_tmp51_ = _tmp53_;
					if (_tmp51_ == NULL) {
						_tmp51_ = "";
					}
					_tmp54_ = g_strdup (_tmp51_);
					description = _tmp54_;
					_tmp55_ = proton_plus_models_internal_meta_info_release_new ();
					release = _tmp55_;
					_tmp56_ = release;
					_tmp57_ = description;
					_tmp58_ = g_strdup (_tmp57_);
					_g_free0 (_tmp56_->description);
					_tmp56_->description = _tmp58_;
					_tmp59_ = release;
					_tmp60_ = date_str;
					_tmp61_ = g_strdup (_tmp60_);
					_g_free0 (_tmp59_->date);
					_tmp59_->date = _tmp61_;
					_tmp62_ = release;
					_tmp63_ = version;
					_tmp64_ = g_strdup (_tmp63_);
					_g_free0 (_tmp62_->version);
					_tmp62_->version = _tmp64_;
					_tmp65_ = self->priv->model;
					_tmp66_ = _tmp65_->releases;
					_tmp67_ = release;
					gee_collection_add ((GeeCollection*) _tmp66_, _tmp67_);
					_g_object_unref0 (release);
					_g_free0 (description);
					_g_free0 (date_str);
					_g_free0 (date_timestamp);
					_g_free0 (version);
					_g_object_unref0 (rel);
				}
			}
		}
		_tmp68_ = self->priv->model;
		_tmp69_ = _g_object_ref0 (_tmp68_);
		result = _tmp69_;
		_g_object_unref0 (releases);
		_g_object_unref0 (component);
		_g_object_unref0 (resource_file);
		_g_object_unref0 (mdata);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp70_;
		const gchar* _tmp71_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp70_ = e;
		_tmp71_ = _tmp70_->message;
		g_warning ("metainfo-loader.vala:102: Parsing metainfo failed: %s", _tmp71_);
		result = NULL;
		_g_error_free0 (e);
		_g_object_unref0 (mdata);
		return result;
	}
	__finally0:
	_g_object_unref0 (mdata);
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static void
proton_plus_utils_internal_meta_info_loader_class_init (ProtonPlusUtilsInternalMetaInfoLoaderClass * klass,
                                                        gpointer klass_data)
{
	proton_plus_utils_internal_meta_info_loader_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusUtilsInternalMetaInfoLoader_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_utils_internal_meta_info_loader_finalize;
}

static void
proton_plus_utils_internal_meta_info_loader_instance_init (ProtonPlusUtilsInternalMetaInfoLoader * self,
                                                           gpointer klass)
{
	self->priv = proton_plus_utils_internal_meta_info_loader_get_instance_private (self);
	self->priv->model = NULL;
}

static void
proton_plus_utils_internal_meta_info_loader_finalize (GObject * obj)
{
	ProtonPlusUtilsInternalMetaInfoLoader * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_UTILS_INTERNAL_TYPE_META_INFO_LOADER, ProtonPlusUtilsInternalMetaInfoLoader);
	_g_object_unref0 (self->priv->model);
	G_OBJECT_CLASS (proton_plus_utils_internal_meta_info_loader_parent_class)->finalize (obj);
}

static GType
proton_plus_utils_internal_meta_info_loader_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsInternalMetaInfoLoaderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_internal_meta_info_loader_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsInternalMetaInfoLoader), 0, (GInstanceInitFunc) proton_plus_utils_internal_meta_info_loader_instance_init, NULL };
	GType proton_plus_utils_internal_meta_info_loader_type_id;
	proton_plus_utils_internal_meta_info_loader_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsInternalMetaInfoLoader", &g_define_type_info, 0);
	ProtonPlusUtilsInternalMetaInfoLoader_private_offset = g_type_add_instance_private (proton_plus_utils_internal_meta_info_loader_type_id, sizeof (ProtonPlusUtilsInternalMetaInfoLoaderPrivate));
	return proton_plus_utils_internal_meta_info_loader_type_id;
}

GType
proton_plus_utils_internal_meta_info_loader_get_type (void)
{
	static volatile gsize proton_plus_utils_internal_meta_info_loader_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_internal_meta_info_loader_type_id__once)) {
		GType proton_plus_utils_internal_meta_info_loader_type_id;
		proton_plus_utils_internal_meta_info_loader_type_id = proton_plus_utils_internal_meta_info_loader_get_type_once ();
		g_once_init_leave (&proton_plus_utils_internal_meta_info_loader_type_id__once, proton_plus_utils_internal_meta_info_loader_type_id);
	}
	return proton_plus_utils_internal_meta_info_loader_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

