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

/*
* Copyright (c) 2011-2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

VALA_EXTERN gchar* terminal_utils_sanitize_path (const gchar* _path,
                                     const gchar* shell_location,
                                     gboolean add_file_scheme);
VALA_EXTERN gchar* terminal_utils_strip_uri (const gchar* _uri);
VALA_EXTERN gchar* terminal_utils_construct_parent_path (const gchar* path);
VALA_EXTERN gchar* terminal_utils_get_parent_path_from_path (const gchar* path);
VALA_EXTERN gboolean terminal_utils_is_safe_paste (const gchar* text,
                                       gchar*** msg_array,
                                       gint* msg_array_length1);
static void _vala_array_add13 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add14 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
static void _vala_array_add15 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static gchar** _vala_array_dup2 (gchar** self,
                          gssize length);
VALA_EXTERN GSimpleAction* terminal_utils_action_from_group (const gchar* action_name,
                                                 GSimpleActionGroup* action_group);
VALA_EXTERN gboolean terminal_utils_valid_local_uri (const gchar* s,
                                         gchar** path);
VALA_EXTERN GAppInfo* terminal_utils_get_default_app_for_uri (const gchar* uri);
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 gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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 gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

gchar*
terminal_utils_sanitize_path (const gchar* _path,
                              const gchar* shell_location,
                              gboolean add_file_scheme)
{
	gchar* scheme = NULL;
	gchar* _tmp0_;
	gchar* path = NULL;
	gchar* _tmp1_;
	gchar** parts_scheme = NULL;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint parts_scheme_length1;
	gint _parts_scheme_size_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	const gchar* _tmp23_;
	gchar** parts_sep = NULL;
	const gchar* _tmp26_;
	gchar** _tmp27_;
	gchar** _tmp28_;
	gint parts_sep_length1;
	gint _parts_sep_size_;
	gint index = 0;
	gchar** _tmp34_;
	gint _tmp34__length1;
	const gchar* _tmp35_;
	gchar* _result_ = NULL;
	const gchar* _tmp47_;
	gchar** _tmp48_;
	gint _tmp48__length1;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* result;
	g_return_val_if_fail (_path != NULL, NULL);
	g_return_val_if_fail (shell_location != NULL, NULL);
	_tmp0_ = g_strdup ("");
	scheme = _tmp0_;
	_tmp1_ = g_strdup ("");
	path = _tmp1_;
	_tmp3_ = _tmp2_ = g_strsplit (_path, "://", 2);
	parts_scheme = _tmp3_;
	parts_scheme_length1 = _vala_array_length (_tmp2_);
	_parts_scheme_size_ = parts_scheme_length1;
	_tmp4_ = parts_scheme;
	_tmp4__length1 = parts_scheme_length1;
	if (_tmp4__length1 == 2) {
		gchar** _tmp5_;
		gint _tmp5__length1;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar** _tmp8_;
		gint _tmp8__length1;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp5_ = parts_scheme;
		_tmp5__length1 = parts_scheme_length1;
		_tmp6_ = _tmp5_[0];
		_tmp7_ = g_strconcat (_tmp6_, "://", NULL);
		_g_free0 (scheme);
		scheme = _tmp7_;
		_tmp8_ = parts_scheme;
		_tmp8__length1 = parts_scheme_length1;
		_tmp9_ = _tmp8_[1];
		_tmp10_ = g_strdup (_tmp9_);
		_g_free0 (path);
		path = _tmp10_;
	} else {
		gchar** _tmp11_;
		gint _tmp11__length1;
		_tmp11_ = parts_scheme;
		_tmp11__length1 = parts_scheme_length1;
		if (_tmp11__length1 == 1) {
			gchar* _tmp13_;
			if (add_file_scheme) {
				gchar* _tmp12_;
				_tmp12_ = g_strdup ("file://");
				_g_free0 (scheme);
				scheme = _tmp12_;
			}
			_tmp13_ = g_strdup (_path);
			_g_free0 (path);
			path = _tmp13_;
		} else {
			g_critical ("Utils.vala:35: Invalid path");
			result = NULL;
			parts_scheme = (_vala_array_free (parts_scheme, parts_scheme_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (path);
			_g_free0 (scheme);
			return result;
		}
	}
	_tmp14_ = path;
	_tmp15_ = g_uri_unescape_string (_tmp14_, NULL);
	_g_free0 (path);
	path = _tmp15_;
	_tmp16_ = path;
	if (_tmp16_ == NULL) {
		result = NULL;
		parts_scheme = (_vala_array_free (parts_scheme, parts_scheme_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (path);
		_g_free0 (scheme);
		return result;
	}
	_tmp17_ = path;
	_tmp18_ = terminal_utils_strip_uri (_tmp17_);
	_g_free0 (path);
	path = _tmp18_;
	{
		gboolean _tmp19_ = FALSE;
		_tmp19_ = TRUE;
		while (TRUE) {
			const gchar* _tmp21_;
			gchar* _tmp22_;
			if (!_tmp19_) {
				const gchar* _tmp20_;
				_tmp20_ = path;
				if (!string_contains (_tmp20_, "//")) {
					break;
				}
			}
			_tmp19_ = FALSE;
			_tmp21_ = path;
			_tmp22_ = string_replace (_tmp21_, "//", "/");
			_g_free0 (path);
			path = _tmp22_;
		}
	}
	_tmp23_ = path;
	if (!string_contains (_tmp23_, G_DIR_SEPARATOR_S)) {
		const gchar* _tmp24_;
		gchar* _tmp25_;
		_tmp24_ = path;
		_tmp25_ = g_strjoin (G_DIR_SEPARATOR_S, ".", _tmp24_, NULL);
		_g_free0 (path);
		path = _tmp25_;
	}
	_tmp26_ = path;
	_tmp28_ = _tmp27_ = g_strsplit (_tmp26_, G_DIR_SEPARATOR_S, 3);
	parts_sep = _tmp28_;
	parts_sep_length1 = _vala_array_length (_tmp27_);
	_parts_sep_size_ = parts_sep_length1;
	index = 0;
	while (TRUE) {
		gboolean _tmp29_ = FALSE;
		gchar** _tmp30_;
		gint _tmp30__length1;
		const gchar* _tmp31_;
		gint _tmp33_;
		_tmp30_ = parts_sep;
		_tmp30__length1 = parts_sep_length1;
		_tmp31_ = _tmp30_[index];
		if (_tmp31_ == NULL) {
			gchar** _tmp32_;
			gint _tmp32__length1;
			_tmp32_ = parts_sep;
			_tmp32__length1 = parts_sep_length1;
			_tmp29_ = index < (_tmp32__length1 - 1);
		} else {
			_tmp29_ = FALSE;
		}
		if (!_tmp29_) {
			break;
		}
		_tmp33_ = index;
		index = _tmp33_ + 1;
	}
	_tmp34_ = parts_sep;
	_tmp34__length1 = parts_sep_length1;
	_tmp35_ = _tmp34_[index];
	if (g_strcmp0 (_tmp35_, "~") == 0) {
		gchar** _tmp36_;
		gint _tmp36__length1;
		const gchar* _tmp37_;
		gchar* _tmp38_;
		_tmp36_ = parts_sep;
		_tmp36__length1 = parts_sep_length1;
		_tmp37_ = g_get_home_dir ();
		_tmp38_ = g_strdup (_tmp37_);
		_g_free0 (_tmp36_[index]);
		_tmp36_[index] = _tmp38_;
	} else {
		gchar** _tmp39_;
		gint _tmp39__length1;
		const gchar* _tmp40_;
		_tmp39_ = parts_sep;
		_tmp39__length1 = parts_sep_length1;
		_tmp40_ = _tmp39_[index];
		if (g_strcmp0 (_tmp40_, ".") == 0) {
			gchar** _tmp41_;
			gint _tmp41__length1;
			gchar* _tmp42_;
			_tmp41_ = parts_sep;
			_tmp41__length1 = parts_sep_length1;
			_tmp42_ = g_strdup (shell_location);
			_g_free0 (_tmp41_[index]);
			_tmp41_[index] = _tmp42_;
		} else {
			gchar** _tmp43_;
			gint _tmp43__length1;
			const gchar* _tmp44_;
			_tmp43_ = parts_sep;
			_tmp43__length1 = parts_sep_length1;
			_tmp44_ = _tmp43_[index];
			if (g_strcmp0 (_tmp44_, "..") == 0) {
				gchar** _tmp45_;
				gint _tmp45__length1;
				gchar* _tmp46_;
				_tmp45_ = parts_sep;
				_tmp45__length1 = parts_sep_length1;
				_tmp46_ = terminal_utils_construct_parent_path (shell_location);
				_g_free0 (_tmp45_[index]);
				_tmp45_[index] = _tmp46_;
			}
		}
	}
	_tmp47_ = scheme;
	_tmp48_ = parts_sep;
	_tmp48__length1 = parts_sep_length1;
	_tmp49_ = _vala_g_strjoinv (G_DIR_SEPARATOR_S, _tmp48_, (gint) _tmp48__length1);
	_tmp50_ = _tmp49_;
	_tmp51_ = string_replace (_tmp50_, "//", "/");
	_tmp52_ = _tmp51_;
	_tmp53_ = g_strconcat (_tmp47_, _tmp52_, NULL);
	_tmp54_ = _tmp53_;
	_g_free0 (_tmp52_);
	_g_free0 (_tmp50_);
	_result_ = _tmp54_;
	result = _result_;
	parts_sep = (_vala_array_free (parts_sep, parts_sep_length1, (GDestroyNotify) g_free), NULL);
	parts_scheme = (_vala_array_free (parts_scheme, parts_scheme_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (path);
	_g_free0 (scheme);
	return result;
}

/*** Simplified version of PF.FileUtils function, with fewer checks ***/
static gint
string_last_index_of (const gchar* self,
                      const gchar* needle,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = g_strrstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

gchar*
terminal_utils_get_parent_path_from_path (const gchar* path)
{
	gint _tmp0_;
	gint _tmp1_;
	GString* string_builder = NULL;
	GString* _tmp3_;
	gint last_separator = 0;
	GString* _tmp9_;
	const gchar* _tmp10_;
	GString* _tmp11_;
	GString* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = strlen (path);
	_tmp1_ = _tmp0_;
	if (_tmp1_ < 2) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (G_DIR_SEPARATOR_S);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = g_string_new (path);
	string_builder = _tmp3_;
	if (g_str_has_suffix (path, G_DIR_SEPARATOR_S)) {
		GString* _tmp4_;
		GString* _tmp5_;
		const gchar* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp4_ = string_builder;
		_tmp5_ = string_builder;
		_tmp6_ = _tmp5_->str;
		_tmp7_ = strlen (_tmp6_);
		_tmp8_ = _tmp7_;
		g_string_erase (_tmp4_, (gssize) (_tmp8_ - 1), (gssize) -1);
	}
	_tmp9_ = string_builder;
	_tmp10_ = _tmp9_->str;
	last_separator = string_last_index_of (_tmp10_, G_DIR_SEPARATOR_S, 0);
	if (last_separator < 0) {
		last_separator = 0;
	}
	_tmp11_ = string_builder;
	g_string_erase (_tmp11_, (gssize) last_separator, (gssize) -1);
	_tmp12_ = string_builder;
	_tmp13_ = _tmp12_->str;
	_tmp14_ = g_strconcat (_tmp13_, G_DIR_SEPARATOR_S, NULL);
	result = _tmp14_;
	_g_string_free0 (string_builder);
	return result;
}

gchar*
terminal_utils_construct_parent_path (const gchar* path)
{
	gint _tmp0_;
	gint _tmp1_;
	GString* sb = NULL;
	GString* _tmp3_;
	gint last_separator = 0;
	GString* _tmp9_;
	const gchar* _tmp10_;
	GString* _tmp11_;
	gchar* parent_path = NULL;
	GString* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = strlen (path);
	_tmp1_ = _tmp0_;
	if (_tmp1_ < 2) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (G_DIR_SEPARATOR_S);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = g_string_new (path);
	sb = _tmp3_;
	if (g_str_has_suffix (path, G_DIR_SEPARATOR_S)) {
		GString* _tmp4_;
		GString* _tmp5_;
		const gchar* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp4_ = sb;
		_tmp5_ = sb;
		_tmp6_ = _tmp5_->str;
		_tmp7_ = strlen (_tmp6_);
		_tmp8_ = _tmp7_;
		g_string_erase (_tmp4_, (gssize) (_tmp8_ - 1), (gssize) -1);
	}
	_tmp9_ = sb;
	_tmp10_ = _tmp9_->str;
	last_separator = string_last_index_of (_tmp10_, G_DIR_SEPARATOR_S, 0);
	if (last_separator < 0) {
		last_separator = 0;
	}
	_tmp11_ = sb;
	g_string_erase (_tmp11_, (gssize) last_separator, (gssize) -1);
	_tmp12_ = sb;
	_tmp13_ = _tmp12_->str;
	_tmp14_ = g_strconcat (_tmp13_, G_DIR_SEPARATOR_S, NULL);
	parent_path = _tmp14_;
	result = parent_path;
	_g_string_free0 (sb);
	return result;
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

gchar*
terminal_utils_strip_uri (const gchar* _uri)
{
	gchar* uri = NULL;
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_strdup (_uri);
	uri = _tmp0_;
	if (_uri != NULL) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp1_ = uri;
		_tmp2_ = string_strip (_tmp1_);
		_g_free0 (uri);
		uri = _tmp2_;
		_tmp3_ = uri;
		_tmp4_ = string_replace (_tmp3_, "\n", "");
		_g_free0 (uri);
		uri = _tmp4_;
		_tmp5_ = uri;
		_tmp6_ = string_replace (_tmp5_, "\r", "");
		_g_free0 (uri);
		uri = _tmp6_;
	}
	result = uri;
	return result;
}

/**
     * Checks a string for possible unsafe contents before pasting
     *
     * @param clipboard contents containing terminal commands
     *
     * @param return localized explanation of risk
     *
     * @return true if safe, false if unsafe.
     */
static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static void
_vala_array_add13 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add14 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gboolean
_vala_string_array_contains (gchar* * stack,
                             gssize stack_length,
                             const gchar* needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
_vala_array_add15 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gchar**
_vala_array_dup2 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

gboolean
terminal_utils_is_safe_paste (const gchar* text,
                              gchar*** msg_array,
                              gint* msg_array_length1)
{
	gchar** _vala_msg_array = NULL;
	gint _vala_msg_array_length1 = 0;
	gchar** msgs = NULL;
	gchar** _tmp0_;
	gint msgs_length1;
	gint _msgs_size_;
	gint newline_index = 0;
	gboolean _tmp1_ = FALSE;
	gboolean embedded_newline = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	gchar** skip_commands = NULL;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar** _tmp19_;
	gint skip_commands_length1;
	gint _skip_commands_size_;
	gchar** words = NULL;
	gchar** _tmp20_;
	gchar** _tmp21_;
	gint words_length1;
	gint _words_size_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar** _tmp26_;
	gint _tmp26__length1;
	gboolean result;
	g_return_val_if_fail (text != NULL, FALSE);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	msgs = _tmp0_;
	msgs_length1 = 0;
	_msgs_size_ = msgs_length1;
	newline_index = string_index_of (text, "\n", 0);
	if (newline_index >= 0) {
		gint _tmp2_;
		gint _tmp3_;
		_tmp2_ = strlen (text);
		_tmp3_ = _tmp2_;
		_tmp1_ = newline_index < (_tmp3_ - 1);
	} else {
		_tmp1_ = FALSE;
	}
	embedded_newline = _tmp1_;
	if (embedded_newline) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = string_contains (text, "&");
	}
	if (_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = string_contains (text, "|");
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = string_contains (text, ";");
	}
	if (_tmp4_) {
		gchar* _tmp7_;
		_tmp7_ = g_strdup (_ ("The pasted text may contain multiple commands"));
		_vala_array_add13 (&msgs, &msgs_length1, &_msgs_size_, _tmp7_);
	}
	if (string_contains (text, "sudo ")) {
		_tmp11_ = TRUE;
	} else {
		_tmp11_ = string_contains (text, "doas ");
	}
	if (_tmp11_) {
		_tmp10_ = TRUE;
	} else {
		_tmp10_ = string_contains (text, "run0 ");
	}
	if (_tmp10_) {
		_tmp9_ = TRUE;
	} else {
		_tmp9_ = string_contains (text, "pkexec ");
	}
	if (_tmp9_) {
		_tmp8_ = TRUE;
	} else {
		_tmp8_ = string_contains (text, "su ");
	}
	if (_tmp8_) {
		gchar* _tmp12_;
		_tmp12_ = g_strdup (_ ("The pasted text may be trying to gain administrative access"));
		_vala_array_add14 (&msgs, &msgs_length1, &_msgs_size_, _tmp12_);
	}
	_tmp13_ = g_strdup ("--assume-yes");
	_tmp14_ = g_strdup ("-f");
	_tmp15_ = g_strdup ("--force");
	_tmp16_ = g_strdup ("--interactive=never");
	_tmp17_ = g_strdup ("-y");
	_tmp18_ = g_strdup ("--yes");
	_tmp19_ = g_new0 (gchar*, 6 + 1);
	_tmp19_[0] = _tmp13_;
	_tmp19_[1] = _tmp14_;
	_tmp19_[2] = _tmp15_;
	_tmp19_[3] = _tmp16_;
	_tmp19_[4] = _tmp17_;
	_tmp19_[5] = _tmp18_;
	skip_commands = _tmp19_;
	skip_commands_length1 = 6;
	_skip_commands_size_ = skip_commands_length1;
	_tmp21_ = _tmp20_ = g_strsplit (text, " ", 0);
	words = _tmp21_;
	words_length1 = _vala_array_length (_tmp20_);
	_words_size_ = words_length1;
	_tmp22_ = skip_commands;
	_tmp22__length1 = skip_commands_length1;
	{
		gchar** skip_command_collection = NULL;
		gint skip_command_collection_length1 = 0;
		gint _skip_command_collection_size_ = 0;
		gint skip_command_it = 0;
		skip_command_collection = _tmp22_;
		skip_command_collection_length1 = _tmp22__length1;
		for (skip_command_it = 0; skip_command_it < skip_command_collection_length1; skip_command_it = skip_command_it + 1) {
			const gchar* skip_command = NULL;
			skip_command = skip_command_collection[skip_command_it];
			{
				const gchar* _tmp23_;
				gchar** _tmp24_;
				gint _tmp24__length1;
				_tmp23_ = skip_command;
				_tmp24_ = words;
				_tmp24__length1 = words_length1;
				if (_vala_string_array_contains (_tmp24_, _tmp24__length1, _tmp23_)) {
					gchar* _tmp25_;
					_tmp25_ = g_strdup (_ ("The pasted text includes a command to skip warnings and confirmations"));
					_vala_array_add15 (&msgs, &msgs_length1, &_msgs_size_, _tmp25_);
					break;
				}
			}
		}
	}
	_tmp26_ = msgs;
	_tmp26__length1 = msgs_length1;
	if (_tmp26__length1 > 0) {
		gchar** _tmp27_;
		gint _tmp27__length1;
		gchar** _tmp28_;
		gint _tmp28__length1;
		_tmp27_ = msgs;
		_tmp27__length1 = msgs_length1;
		_tmp28_ = (_tmp27_ != NULL) ? _vala_array_dup2 (_tmp27_, _tmp27__length1) : _tmp27_;
		_tmp28__length1 = _tmp27__length1;
		_vala_msg_array = (_vala_array_free (_vala_msg_array, _vala_msg_array_length1, (GDestroyNotify) g_free), NULL);
		_vala_msg_array = _tmp28_;
		_vala_msg_array_length1 = _tmp28__length1;
		result = FALSE;
		words = (_vala_array_free (words, words_length1, (GDestroyNotify) g_free), NULL);
		skip_commands = (_vala_array_free (skip_commands, skip_commands_length1, (GDestroyNotify) g_free), NULL);
		msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_free), NULL);
		if (msg_array) {
			*msg_array = _vala_msg_array;
		} else {
			_vala_msg_array = (_vala_array_free (_vala_msg_array, _vala_msg_array_length1, (GDestroyNotify) g_free), NULL);
		}
		if (msg_array_length1) {
			*msg_array_length1 = _vala_msg_array_length1;
		}
		return result;
	} else {
		_vala_msg_array = (_vala_array_free (_vala_msg_array, _vala_msg_array_length1, (GDestroyNotify) g_free), NULL);
		_vala_msg_array = NULL;
		_vala_msg_array_length1 = 0;
		result = TRUE;
		words = (_vala_array_free (words, words_length1, (GDestroyNotify) g_free), NULL);
		skip_commands = (_vala_array_free (skip_commands, skip_commands_length1, (GDestroyNotify) g_free), NULL);
		msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_free), NULL);
		if (msg_array) {
			*msg_array = _vala_msg_array;
		} else {
			_vala_msg_array = (_vala_array_free (_vala_msg_array, _vala_msg_array_length1, (GDestroyNotify) g_free), NULL);
		}
		if (msg_array_length1) {
			*msg_array_length1 = _vala_msg_array_length1;
		}
		return result;
	}
}

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

GSimpleAction*
terminal_utils_action_from_group (const gchar* action_name,
                                  GSimpleActionGroup* action_group)
{
	GAction* _tmp0_;
	GSimpleAction* _tmp1_;
	GSimpleAction* result;
	g_return_val_if_fail (action_name != NULL, NULL);
	g_return_val_if_fail (action_group != NULL, NULL);
	_tmp0_ = g_action_map_lookup_action ((GActionMap*) action_group, action_name);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, g_simple_action_get_type (), GSimpleAction));
	result = _tmp1_;
	return result;
}

gboolean
terminal_utils_valid_local_uri (const gchar* s,
                                gchar** path)
{
	gchar* _vala_path = NULL;
	gchar* scheme = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* absolute_uri = NULL;
	gboolean _tmp3_ = FALSE;
	const gchar* _tmp4_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (s != NULL, FALSE);
	_tmp0_ = g_uri_peek_scheme (s);
	_tmp1_ = g_strdup (_tmp0_);
	scheme = _tmp1_;
	_tmp2_ = g_strdup ("");
	_g_free0 (_vala_path);
	_vala_path = _tmp2_;
	_tmp4_ = scheme;
	if (_tmp4_ == NULL) {
		_tmp3_ = TRUE;
	} else {
		const gchar* _tmp5_;
		_tmp5_ = scheme;
		_tmp3_ = g_strcmp0 (_tmp5_, "") == 0;
	}
	if (_tmp3_) {
		gchar* _tmp6_;
		_tmp6_ = g_strconcat ("file:///", s, NULL);
		_g_free0 (absolute_uri);
		absolute_uri = _tmp6_;
	} else {
		const gchar* _tmp7_;
		_tmp7_ = scheme;
		if (g_strcmp0 (_tmp7_, "file") != 0) {
			result = FALSE;
			_g_free0 (absolute_uri);
			_g_free0 (scheme);
			if (path) {
				*path = _vala_path;
			} else {
				_g_free0 (_vala_path);
			}
			return result;
		} else {
			gchar* _tmp8_;
			_tmp8_ = g_strdup (s);
			_g_free0 (absolute_uri);
			absolute_uri = _tmp8_;
		}
	}
	{
		gboolean _tmp9_ = FALSE;
		const gchar* _tmp10_;
		GFile* file = NULL;
		const gchar* _tmp11_;
		GFile* _tmp12_;
		GFileType type = 0;
		GFile* _tmp13_;
		_tmp10_ = absolute_uri;
		_tmp9_ = g_uri_is_valid (_tmp10_, G_URI_FLAGS_PARSE_RELAXED, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (!_tmp9_) {
			result = FALSE;
			_g_free0 (absolute_uri);
			_g_free0 (scheme);
			if (path) {
				*path = _vala_path;
			} else {
				_g_free0 (_vala_path);
			}
			return result;
		}
		_tmp11_ = absolute_uri;
		_tmp12_ = g_file_new_for_uri (_tmp11_);
		file = _tmp12_;
		_tmp13_ = file;
		type = g_file_query_file_type (_tmp13_, G_FILE_QUERY_INFO_NONE, NULL);
		if (type == G_FILE_TYPE_DIRECTORY) {
			GFile* _tmp14_;
			gchar* _tmp15_;
			_tmp14_ = file;
			_tmp15_ = g_file_get_path (_tmp14_);
			_g_free0 (_vala_path);
			_vala_path = _tmp15_;
		} else {
			if (type == G_FILE_TYPE_REGULAR) {
				GFile* _tmp16_;
				GFile* _tmp17_;
				GFile* _tmp18_;
				gchar* _tmp19_;
				_tmp16_ = file;
				_tmp17_ = g_file_get_parent (_tmp16_);
				_tmp18_ = _tmp17_;
				_tmp19_ = g_file_get_path (_tmp18_);
				_g_free0 (_vala_path);
				_vala_path = _tmp19_;
				_g_object_unref0 (_tmp18_);
			} else {
				result = FALSE;
				_g_object_unref0 (file);
				_g_free0 (absolute_uri);
				_g_free0 (scheme);
				if (path) {
					*path = _vala_path;
				} else {
					_g_free0 (_vala_path);
				}
				return result;
			}
		}
		result = TRUE;
		_g_object_unref0 (file);
		_g_free0 (absolute_uri);
		_g_free0 (scheme);
		if (path) {
			*path = _vala_path;
		} else {
			_g_free0 (_vala_path);
		}
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp20_;
		const gchar* _tmp21_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp20_ = e;
		_tmp21_ = _tmp20_->message;
		g_warning ("Utils.vala:208: Error parsing uri - %s", _tmp21_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp22_ = FALSE;
		_g_free0 (absolute_uri);
		_g_free0 (scheme);
		_g_free0 (_vala_path);
		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 _tmp22_;
	}
	result = FALSE;
	_g_free0 (absolute_uri);
	_g_free0 (scheme);
	if (path) {
		*path = _vala_path;
	} else {
		_g_free0 (_vala_path);
	}
	return result;
}

GAppInfo*
terminal_utils_get_default_app_for_uri (const gchar* uri)
{
	GAppInfo* appinfo = NULL;
	gchar* scheme = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	GAppInfo* _tmp4_;
	GError* _inner_error0_ = NULL;
	GAppInfo* result;
	if (uri == NULL) {
		result = NULL;
		return result;
	}
	appinfo = NULL;
	_tmp0_ = g_uri_parse_scheme (uri);
	scheme = _tmp0_;
	_tmp1_ = scheme;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		GAppInfo* _tmp3_;
		_tmp2_ = scheme;
		_tmp3_ = g_app_info_get_default_for_uri_scheme (_tmp2_);
		_g_object_unref0 (appinfo);
		appinfo = _tmp3_;
	}
	_tmp4_ = appinfo;
	if (_tmp4_ == NULL) {
		gboolean uncertain = FALSE;
		gchar* ctype = NULL;
		gboolean _tmp5_ = FALSE;
		gchar* _tmp6_;
		GAppInfo* _tmp9_;
		_tmp6_ = g_content_type_guess (uri, NULL, (gsize) 0, &_tmp5_);
		uncertain = _tmp5_;
		ctype = _tmp6_;
		if (!uncertain) {
			const gchar* _tmp7_;
			GAppInfo* _tmp8_;
			_tmp7_ = ctype;
			_tmp8_ = g_app_info_get_default_for_type (_tmp7_, TRUE);
			_g_object_unref0 (appinfo);
			appinfo = _tmp8_;
		}
		_tmp9_ = appinfo;
		if (_tmp9_ == NULL) {
			GFile* file = NULL;
			GFile* _tmp10_;
			_tmp10_ = g_file_new_for_commandline_arg (uri);
			file = _tmp10_;
			{
				GFileInfo* info = NULL;
				GFile* _tmp11_;
				GFileInfo* _tmp12_;
				GFileInfo* _tmp13_;
				_tmp11_ = file;
				_tmp12_ = g_file_query_info (_tmp11_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error0_);
				info = _tmp12_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp13_ = info;
				if (g_file_info_has_attribute (_tmp13_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)) {
					GFileInfo* _tmp14_;
					const gchar* _tmp15_;
					GAppInfo* _tmp16_;
					_tmp14_ = info;
					_tmp15_ = g_file_info_get_attribute_string (_tmp14_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
					_tmp16_ = g_app_info_get_default_for_type (_tmp15_, TRUE);
					_g_object_unref0 (appinfo);
					appinfo = _tmp16_;
				}
				_g_object_unref0 (info);
			}
			goto __finally0;
			__catch0_g_error:
			{
				GError* e = NULL;
				GError* _tmp17_;
				const gchar* _tmp18_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp17_ = e;
				_tmp18_ = _tmp17_->message;
				g_warning ("Utils.vala:245: Could not get file info %s", _tmp18_);
				_g_error_free0 (e);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (file);
				_g_free0 (ctype);
				_g_free0 (scheme);
				_g_object_unref0 (appinfo);
				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;
			}
			_g_object_unref0 (file);
		}
		_g_free0 (ctype);
	}
	result = appinfo;
	_g_free0 (scheme);
	return result;
}

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 gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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;
}

