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

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2026 elementary, Inc. (https://elementary.io)
 *                         2010 mathijshenquet
 */

#include "pantheon-files-core.h"
#include <gio/gio.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <granite.h>
#include <glib/gi18n-lib.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  {
	FILES_VIEW_CHROME_VIEW_SWITCHER_0_PROPERTY,
	FILES_VIEW_CHROME_VIEW_SWITCHER_ACTION_PROPERTY,
	FILES_VIEW_CHROME_VIEW_SWITCHER_NUM_PROPERTIES
};
static GParamSpec* files_view_chrome_view_switcher_properties[FILES_VIEW_CHROME_VIEW_SWITCHER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block41Data Block41Data;

struct _FilesViewChromeViewSwitcherPrivate {
	GSimpleAction* _action;
};

struct _Block41Data {
	int _ref_count_;
	FilesViewChromeViewSwitcher* self;
	guint32 mode;
};

static gint FilesViewChromeViewSwitcher_private_offset;
static gpointer files_view_chrome_view_switcher_parent_class = NULL;

static gchar* files_view_chrome_view_switcher_get_tooltip_for_id (FilesViewChromeViewSwitcher* self,
                                                           guint32 id,
                                                           const gchar* description);
static void files_view_chrome_view_switcher_on_mode_changed (FilesViewChromeViewSwitcher* self,
                                                      GtkToggleButton* source);
static GVariant* _variant_new1 (guint32 value);
static Block41Data* block41_data_ref (Block41Data* _data41_);
static void block41_data_unref (void * _userdata_);
static void __lambda70_ (Block41Data* _data41_,
                  GtkWidget* child);
static GVariant* _variant_new2 (guint32 value);
static void ___lambda70__gtk_callback (GtkWidget* widget,
                                gpointer self);
static GObject * files_view_chrome_view_switcher_constructor (GType type,
                                                       guint n_construct_properties,
                                                       GObjectConstructParam * construct_properties);
static void _files_view_chrome_view_switcher_on_mode_changed_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                                 gpointer self);
static void files_view_chrome_view_switcher_finalize (GObject * obj);
static GType files_view_chrome_view_switcher_get_type_once (void);
static void _vala_files_view_chrome_view_switcher_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_files_view_chrome_view_switcher_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);
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 inline gpointer
files_view_chrome_view_switcher_get_instance_private (FilesViewChromeViewSwitcher* self)
{
	return G_STRUCT_MEMBER_P (self, FilesViewChromeViewSwitcher_private_offset);
}

FilesViewChromeViewSwitcher*
files_view_chrome_view_switcher_construct (GType object_type,
                                           GSimpleAction* view_mode_action)
{
	FilesViewChromeViewSwitcher * self = NULL;
	g_return_val_if_fail (view_mode_action != NULL, NULL);
	self = (FilesViewChromeViewSwitcher*) g_object_new (object_type, "action", view_mode_action, NULL);
	return self;
}

FilesViewChromeViewSwitcher*
files_view_chrome_view_switcher_new (GSimpleAction* view_mode_action)
{
	return files_view_chrome_view_switcher_construct (FILES_VIEW_CHROME_TYPE_VIEW_SWITCHER, view_mode_action);
}

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

static gchar*
files_view_chrome_view_switcher_get_tooltip_for_id (FilesViewChromeViewSwitcher* self,
                                                    guint32 id,
                                                    const gchar* description)
{
	GtkApplication* app = NULL;
	GApplication* _tmp0_;
	GtkApplication* _tmp1_;
	gchar* detailed_name = NULL;
	GSimpleAction* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GVariant* _tmp7_;
	GVariant* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar** accels = NULL;
	gchar** _tmp11_;
	gchar** _tmp12_;
	gint accels_length1;
	gint _accels_size_;
	gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (description != NULL, NULL);
	_tmp0_ = g_application_get_default ();
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_application_get_type (), GtkApplication));
	app = _tmp1_;
	_tmp2_ = self->priv->_action;
	_tmp3_ = g_action_get_name ((GAction*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strconcat ("win.", _tmp4_, NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_variant_new_uint32 (id);
	g_variant_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_action_print_detailed_name (_tmp6_, _tmp8_);
	_tmp10_ = _tmp9_;
	_g_variant_unref0 (_tmp8_);
	_g_free0 (_tmp6_);
	detailed_name = _tmp10_;
	_tmp12_ = _tmp11_ = gtk_application_get_accels_for_action (app, detailed_name);
	accels = _tmp12_;
	accels_length1 = _vala_array_length (_tmp11_);
	_accels_size_ = accels_length1;
	_tmp13_ = granite_markup_accel_tooltip (accels, (gint) accels_length1, description);
	result = _tmp13_;
	accels = (_vala_array_free (accels, accels_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (detailed_name);
	_g_object_unref0 (app);
	return result;
}

static GVariant*
_variant_new1 (guint32 value)
{
	return g_variant_ref_sink (g_variant_new_uint32 (value));
}

static void
files_view_chrome_view_switcher_on_mode_changed (FilesViewChromeViewSwitcher* self,
                                                 GtkToggleButton* source)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	GSimpleAction* _tmp2_;
	gconstpointer _tmp3_;
	GVariant* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	_tmp0_ = gtk_toggle_button_get_active (source);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	_tmp2_ = self->priv->_action;
	_tmp3_ = g_object_get_data ((GObject*) source, "id");
	_tmp4_ = _variant_new1 ((guint32) ((guintptr) _tmp3_));
	g_signal_emit_by_name (_tmp2_, "activate", _tmp4_);
	_g_variant_unref0 (_tmp4_);
}

static Block41Data*
block41_data_ref (Block41Data* _data41_)
{
	g_atomic_int_inc (&_data41_->_ref_count_);
	return _data41_;
}

static void
block41_data_unref (void * _userdata_)
{
	Block41Data* _data41_;
	_data41_ = (Block41Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data41_->_ref_count_)) {
		FilesViewChromeViewSwitcher* self;
		self = _data41_->self;
		_g_object_unref0 (self);
		g_slice_free (Block41Data, _data41_);
	}
}

static GVariant*
_variant_new2 (guint32 value)
{
	return g_variant_ref_sink (g_variant_new_uint32 (value));
}

static void
__lambda70_ (Block41Data* _data41_,
             GtkWidget* child)
{
	FilesViewChromeViewSwitcher* self;
	gconstpointer _tmp0_;
	self = _data41_->self;
	g_return_if_fail (child != NULL);
	_tmp0_ = g_object_get_data ((GObject*) child, "id");
	if (((guint32) ((guintptr) _tmp0_)) == _data41_->mode) {
		GSimpleAction* _tmp1_;
		gconstpointer _tmp2_;
		GVariant* _tmp3_;
		gtk_toggle_button_set_active ((GtkToggleButton*) G_TYPE_CHECK_INSTANCE_CAST (child, gtk_radio_button_get_type (), GtkRadioButton), TRUE);
		_tmp1_ = self->priv->_action;
		_tmp2_ = g_object_get_data ((GObject*) child, "id");
		_tmp3_ = _variant_new2 ((guint32) ((guintptr) _tmp2_));
		g_signal_emit_by_name (_tmp1_, "activate", _tmp3_);
		_g_variant_unref0 (_tmp3_);
	}
}

static void
___lambda70__gtk_callback (GtkWidget* widget,
                           gpointer self)
{
	__lambda70_ (self, widget);
}

void
files_view_chrome_view_switcher_set_mode (FilesViewChromeViewSwitcher* self,
                                          guint32 mode)
{
	Block41Data* _data41_;
	g_return_if_fail (self != NULL);
	_data41_ = g_slice_new0 (Block41Data);
	_data41_->_ref_count_ = 1;
	_data41_->self = g_object_ref (self);
	_data41_->mode = mode;
	gtk_container_foreach ((GtkContainer*) self, ___lambda70__gtk_callback, _data41_);
	block41_data_unref (_data41_);
	_data41_ = NULL;
}

GSimpleAction*
files_view_chrome_view_switcher_get_action (FilesViewChromeViewSwitcher* self)
{
	GSimpleAction* result;
	GSimpleAction* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_action;
	result = _tmp0_;
	return result;
}

static void
files_view_chrome_view_switcher_set_action (FilesViewChromeViewSwitcher* self,
                                            GSimpleAction* value)
{
	GSimpleAction* old_value;
	g_return_if_fail (self != NULL);
	old_value = files_view_chrome_view_switcher_get_action (self);
	if (old_value != value) {
		GSimpleAction* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_action);
		self->priv->_action = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, files_view_chrome_view_switcher_properties[FILES_VIEW_CHROME_VIEW_SWITCHER_ACTION_PROPERTY]);
	}
}

static void
_files_view_chrome_view_switcher_on_mode_changed_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                            gpointer self)
{
	files_view_chrome_view_switcher_on_mode_changed ((FilesViewChromeViewSwitcher*) self, _sender);
}

static GObject *
files_view_chrome_view_switcher_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FilesViewChromeViewSwitcher * self;
	GtkStyleContext* _tmp0_;
	guint32 id = 0U;
	GtkRadioButton* grid_view_btn = NULL;
	GtkImage* _tmp1_;
	gchar* _tmp2_;
	GtkRadioButton* _tmp3_ = NULL;
	GtkRadioButton* _tmp4_;
	GtkRadioButton* _tmp5_;
	GtkRadioButton* _tmp6_;
	GtkRadioButton* list_view_btn = NULL;
	GtkRadioButton* _tmp7_;
	GtkImage* _tmp8_;
	gchar* _tmp9_;
	GtkRadioButton* _tmp10_ = NULL;
	GtkRadioButton* _tmp11_;
	GtkRadioButton* _tmp12_;
	GtkRadioButton* _tmp13_;
	GtkRadioButton* column_view_btn = NULL;
	GtkRadioButton* _tmp14_;
	GtkImage* _tmp15_;
	gchar* _tmp16_;
	GtkRadioButton* _tmp17_ = NULL;
	GtkRadioButton* _tmp18_;
	GtkRadioButton* _tmp19_;
	GtkRadioButton* _tmp20_;
	GtkRadioButton* _tmp21_;
	GtkRadioButton* _tmp22_;
	GtkRadioButton* _tmp23_;
	parent_class = G_OBJECT_CLASS (files_view_chrome_view_switcher_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FILES_VIEW_CHROME_TYPE_VIEW_SWITCHER, FilesViewChromeViewSwitcher);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp0_, GTK_STYLE_CLASS_LINKED);
	id = (guint32) FILES_VIEW_MODE_ICON;
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("view-grid-symbolic", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp1_);
	_tmp2_ = files_view_chrome_view_switcher_get_tooltip_for_id (self, id, _ ("View as Grid"));
	_tmp3_ = (GtkRadioButton*) gtk_radio_button_new (NULL);
	gtk_button_set_image ((GtkButton*) _tmp3_, (GtkWidget*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp3_, _tmp2_);
	_g_free0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	grid_view_btn = _tmp3_;
	_tmp4_ = grid_view_btn;
	gtk_toggle_button_set_mode ((GtkToggleButton*) _tmp4_, FALSE);
	_tmp5_ = grid_view_btn;
	g_signal_connect_object ((GtkToggleButton*) _tmp5_, "toggled", (GCallback) _files_view_chrome_view_switcher_on_mode_changed_gtk_toggle_button_toggled, self, 0);
	_tmp6_ = grid_view_btn;
	g_object_set_data_full ((GObject*) _tmp6_, "id", (gpointer) ((guintptr) id), NULL);
	id = (guint32) FILES_VIEW_MODE_LIST;
	_tmp7_ = grid_view_btn;
	_tmp8_ = (GtkImage*) gtk_image_new_from_icon_name ("view-list-symbolic", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp8_);
	_tmp9_ = files_view_chrome_view_switcher_get_tooltip_for_id (self, id, _ ("View as List"));
	_tmp10_ = (GtkRadioButton*) gtk_radio_button_new_from_widget (_tmp7_);
	gtk_button_set_image ((GtkButton*) _tmp10_, (GtkWidget*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp10_, _tmp9_);
	_g_free0 (_tmp9_);
	g_object_ref_sink (_tmp10_);
	list_view_btn = _tmp10_;
	_tmp11_ = list_view_btn;
	gtk_toggle_button_set_mode ((GtkToggleButton*) _tmp11_, FALSE);
	_tmp12_ = list_view_btn;
	g_signal_connect_object ((GtkToggleButton*) _tmp12_, "toggled", (GCallback) _files_view_chrome_view_switcher_on_mode_changed_gtk_toggle_button_toggled, self, 0);
	_tmp13_ = list_view_btn;
	g_object_set_data_full ((GObject*) _tmp13_, "id", (gpointer) ((guintptr) id), NULL);
	id = (guint32) FILES_VIEW_MODE_MILLER_COLUMNS;
	_tmp14_ = grid_view_btn;
	_tmp15_ = (GtkImage*) gtk_image_new_from_icon_name ("view-column-symbolic", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp15_);
	_tmp16_ = files_view_chrome_view_switcher_get_tooltip_for_id (self, id, _ ("View in Columns"));
	_tmp17_ = (GtkRadioButton*) gtk_radio_button_new_from_widget (_tmp14_);
	gtk_button_set_image ((GtkButton*) _tmp17_, (GtkWidget*) _tmp15_);
	_g_object_unref0 (_tmp15_);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp17_, _tmp16_);
	_g_free0 (_tmp16_);
	g_object_ref_sink (_tmp17_);
	column_view_btn = _tmp17_;
	_tmp18_ = column_view_btn;
	gtk_toggle_button_set_mode ((GtkToggleButton*) _tmp18_, FALSE);
	_tmp19_ = column_view_btn;
	g_signal_connect_object ((GtkToggleButton*) _tmp19_, "toggled", (GCallback) _files_view_chrome_view_switcher_on_mode_changed_gtk_toggle_button_toggled, self, 0);
	_tmp20_ = column_view_btn;
	g_object_set_data_full ((GObject*) _tmp20_, "id", (gpointer) ((gintptr) FILES_VIEW_MODE_MILLER_COLUMNS), NULL);
	gtk_widget_set_valign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	_tmp21_ = grid_view_btn;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp21_);
	_tmp22_ = list_view_btn;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp22_);
	_tmp23_ = column_view_btn;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp23_);
	_g_object_unref0 (column_view_btn);
	_g_object_unref0 (list_view_btn);
	_g_object_unref0 (grid_view_btn);
	return obj;
}

static void
files_view_chrome_view_switcher_class_init (FilesViewChromeViewSwitcherClass * klass,
                                            gpointer klass_data)
{
	files_view_chrome_view_switcher_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FilesViewChromeViewSwitcher_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_files_view_chrome_view_switcher_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_files_view_chrome_view_switcher_set_property;
	G_OBJECT_CLASS (klass)->constructor = files_view_chrome_view_switcher_constructor;
	G_OBJECT_CLASS (klass)->finalize = files_view_chrome_view_switcher_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FILES_VIEW_CHROME_VIEW_SWITCHER_ACTION_PROPERTY, files_view_chrome_view_switcher_properties[FILES_VIEW_CHROME_VIEW_SWITCHER_ACTION_PROPERTY] = g_param_spec_object ("action", "action", "action", g_simple_action_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
files_view_chrome_view_switcher_instance_init (FilesViewChromeViewSwitcher * self,
                                               gpointer klass)
{
	self->priv = files_view_chrome_view_switcher_get_instance_private (self);
}

static void
files_view_chrome_view_switcher_finalize (GObject * obj)
{
	FilesViewChromeViewSwitcher * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FILES_VIEW_CHROME_TYPE_VIEW_SWITCHER, FilesViewChromeViewSwitcher);
	_g_object_unref0 (self->priv->_action);
	G_OBJECT_CLASS (files_view_chrome_view_switcher_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
files_view_chrome_view_switcher_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FilesViewChromeViewSwitcherClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) files_view_chrome_view_switcher_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FilesViewChromeViewSwitcher), 0, (GInstanceInitFunc) files_view_chrome_view_switcher_instance_init, NULL };
	GType files_view_chrome_view_switcher_type_id;
	files_view_chrome_view_switcher_type_id = g_type_register_static (gtk_box_get_type (), "FilesViewChromeViewSwitcher", &g_define_type_info, 0);
	FilesViewChromeViewSwitcher_private_offset = g_type_add_instance_private (files_view_chrome_view_switcher_type_id, sizeof (FilesViewChromeViewSwitcherPrivate));
	return files_view_chrome_view_switcher_type_id;
}

GType
files_view_chrome_view_switcher_get_type (void)
{
	static volatile gsize files_view_chrome_view_switcher_type_id__once = 0;
	if (g_once_init_enter (&files_view_chrome_view_switcher_type_id__once)) {
		GType files_view_chrome_view_switcher_type_id;
		files_view_chrome_view_switcher_type_id = files_view_chrome_view_switcher_get_type_once ();
		g_once_init_leave (&files_view_chrome_view_switcher_type_id__once, files_view_chrome_view_switcher_type_id);
	}
	return files_view_chrome_view_switcher_type_id__once;
}

static void
_vala_files_view_chrome_view_switcher_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	FilesViewChromeViewSwitcher * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FILES_VIEW_CHROME_TYPE_VIEW_SWITCHER, FilesViewChromeViewSwitcher);
	switch (property_id) {
		case FILES_VIEW_CHROME_VIEW_SWITCHER_ACTION_PROPERTY:
		g_value_set_object (value, files_view_chrome_view_switcher_get_action (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_files_view_chrome_view_switcher_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	FilesViewChromeViewSwitcher * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FILES_VIEW_CHROME_TYPE_VIEW_SWITCHER, FilesViewChromeViewSwitcher);
	switch (property_id) {
		case FILES_VIEW_CHROME_VIEW_SWITCHER_ACTION_PROPERTY:
		files_view_chrome_view_switcher_set_action (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

