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

/*
* Copyright (c) 2018-2026 (https://github.com/phase1geo/Minder)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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 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
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <libxml/tree.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <cairo-gobject.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
#include <webp/encode.h>
#include <stdio.h>
#include <webp/decode.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 TYPE_EXPORT (export_get_type ())
#define EXPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORT, Export))
#define EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORT, ExportClass))
#define IS_EXPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORT))
#define IS_EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORT))
#define EXPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORT, ExportClass))

typedef struct _Export Export;
typedef struct _ExportClass ExportClass;
typedef struct _ExportPrivate ExportPrivate;

#define TYPE_MIND_MAP (mind_map_get_type ())
#define MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIND_MAP, MindMap))
#define MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIND_MAP, MindMapClass))
#define IS_MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIND_MAP))
#define IS_MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIND_MAP))
#define MIND_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIND_MAP, MindMapClass))

typedef struct _MindMap MindMap;
typedef struct _MindMapClass MindMapClass;

#define TYPE_EXPORT_WEB_P (export_web_p_get_type ())
#define EXPORT_WEB_P(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORT_WEB_P, ExportWebP))
#define EXPORT_WEB_P_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORT_WEB_P, ExportWebPClass))
#define IS_EXPORT_WEB_P(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORT_WEB_P))
#define IS_EXPORT_WEB_P_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORT_WEB_P))
#define EXPORT_WEB_P_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORT_WEB_P, ExportWebPClass))

typedef struct _ExportWebP ExportWebP;
typedef struct _ExportWebPClass ExportWebPClass;
typedef struct _ExportWebPPrivate ExportWebPPrivate;

#define TYPE_MAP_MODEL (map_model_get_type ())
#define MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAP_MODEL, MapModel))
#define MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAP_MODEL, MapModelClass))
#define IS_MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAP_MODEL))
#define IS_MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAP_MODEL))
#define MAP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAP_MODEL, MapModelClass))

typedef struct _MapModel MapModel;
typedef struct _MapModelClass MapModelClass;

#define TYPE_DRAW_AREA (draw_area_get_type ())
#define DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DRAW_AREA, DrawArea))
#define DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DRAW_AREA, DrawAreaClass))
#define IS_DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DRAW_AREA))
#define IS_DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DRAW_AREA))
#define DRAW_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DRAW_AREA, DrawAreaClass))

typedef struct _DrawArea DrawArea;
typedef struct _DrawAreaClass DrawAreaClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _Export {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ExportPrivate * priv;
};

struct _ExportClass {
	GTypeClass parent_class;
	void (*finalize) (Export *self);
	gboolean (*export) (Export* self, const gchar* fname, MindMap* map);
	gboolean (*import) (Export* self, const gchar* fname, MindMap* map);
	void (*add_settings) (Export* self, GtkGrid* grid);
	void (*save_settings) (Export* self, xmlNode* node);
	void (*load_settings) (Export* self, xmlNode* node);
};

struct _ExportWebP {
	Export parent_instance;
	ExportWebPPrivate * priv;
};

struct _ExportWebPClass {
	ExportClass parent_class;
};

static gpointer export_web_p_parent_class = NULL;

VALA_EXTERN gpointer export_ref (gpointer instance);
VALA_EXTERN void export_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_export (const gchar* name,
                               const gchar* nick,
                               const gchar* blurb,
                               GType object_type,
                               GParamFlags flags);
VALA_EXTERN void value_set_export (GValue* value,
                       gpointer v_object);
VALA_EXTERN void value_take_export (GValue* value,
                        gpointer v_object);
VALA_EXTERN gpointer value_get_export (const GValue* value);
VALA_EXTERN GType export_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Export, export_unref)
VALA_EXTERN gpointer mind_map_ref (gpointer instance);
VALA_EXTERN void mind_map_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_mind_map (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_mind_map (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_mind_map (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_mind_map (const GValue* value);
VALA_EXTERN GType mind_map_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MindMap, mind_map_unref)
VALA_EXTERN GType export_web_p_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ExportWebP, export_unref)
VALA_EXTERN gboolean export_export (Export* self,
                        const gchar* fname,
                        MindMap* map);
VALA_EXTERN ExportWebP* export_web_p_new (void);
VALA_EXTERN ExportWebP* export_web_p_construct (GType object_type);
VALA_EXTERN Export* export_new (const gchar* name,
                    const gchar* label,
                    gchar** extensions,
                    gint extensions_length1,
                    gboolean exportable,
                    gboolean importable,
                    gboolean dir,
                    gboolean clippable);
VALA_EXTERN Export* export_construct (GType object_type,
                          const gchar* name,
                          const gchar* label,
                          gchar** extensions,
                          gint extensions_length1,
                          gboolean exportable,
                          gboolean importable,
                          gboolean dir,
                          gboolean clippable);
static gboolean export_web_p_real_export (Export* base,
                                   const gchar* fname,
                                   MindMap* map);
VALA_EXTERN gpointer map_model_ref (gpointer instance);
VALA_EXTERN void map_model_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_map_model (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_map_model (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_map_model (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_map_model (const GValue* value);
VALA_EXTERN GType map_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MapModel, map_model_unref)
VALA_EXTERN MapModel* mind_map_get_model (MindMap* self);
VALA_EXTERN void map_model_document_rectangle (MapModel* self,
                                   gdouble* x,
                                   gdouble* y,
                                   gdouble* width,
                                   gdouble* height);
VALA_EXTERN GType draw_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DrawArea, g_object_unref)
VALA_EXTERN DrawArea* mind_map_get_canvas (MindMap* self);
VALA_EXTERN void map_model_draw_all (MapModel* self,
                         cairo_t* ctx,
                         gboolean exporting,
                         gboolean moving_node);
static void _vala_array_add53 (guint8* * array,
                        gint* length,
                        gint* size,
                        guint8 value);
static GType export_web_p_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);

ExportWebP*
export_web_p_construct (GType object_type)
{
	ExportWebP* self = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	_tmp0_ = g_strdup (".webp");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = 1;
	self = (ExportWebP*) export_construct (object_type, "webp", _ ("WebP"), _tmp2_, (gint) 1, TRUE, TRUE, FALSE, FALSE);
	_tmp2_ = (_vala_array_free (_tmp2_, _tmp2__length1, (GDestroyNotify) g_free), NULL);
	return self;
}

ExportWebP*
export_web_p_new (void)
{
	return export_web_p_construct (TYPE_EXPORT_WEB_P);
}

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

static gboolean
export_web_p_real_export (Export* base,
                          const gchar* fname,
                          MindMap* map)
{
	ExportWebP * self;
	gdouble x = 0.0;
	gdouble y = 0.0;
	gdouble w = 0.0;
	gdouble h = 0.0;
	MapModel* _tmp0_;
	MapModel* _tmp1_;
	gdouble _tmp2_ = 0.0;
	gdouble _tmp3_ = 0.0;
	gdouble _tmp4_ = 0.0;
	gdouble _tmp5_ = 0.0;
	cairo_surface_t* surface = NULL;
	cairo_surface_t* _tmp6_;
	cairo_t* context = NULL;
	cairo_surface_t* _tmp7_;
	cairo_t* _tmp8_;
	DrawArea* _tmp9_;
	DrawArea* _tmp10_;
	GtkStyleContext* _tmp11_;
	cairo_t* _tmp12_;
	cairo_t* _tmp13_;
	MapModel* _tmp14_;
	MapModel* _tmp15_;
	cairo_t* _tmp16_;
	GdkPixbuf* pixbuf = NULL;
	cairo_surface_t* _tmp17_;
	GdkPixbuf* _tmp18_;
	GdkPixbuf* _tmp19_;
	GdkPixbuf* _tmp20_;
	guint8* output_buffer = NULL;
	gsize buffer_size = 0UL;
	GdkPixbuf* _tmp21_;
	guint8* _tmp22_;
	GdkPixbuf* _tmp23_;
	GdkPixbuf* _tmp24_;
	GdkPixbuf* _tmp25_;
	guint8* _tmp26_ = NULL;
	gsize _tmp27_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (ExportWebP*) base;
	g_return_val_if_fail (fname != NULL, FALSE);
	g_return_val_if_fail (map != NULL, FALSE);
	_tmp0_ = mind_map_get_model (map);
	_tmp1_ = _tmp0_;
	map_model_document_rectangle (_tmp1_, &_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_);
	x = _tmp2_;
	y = _tmp3_;
	w = _tmp4_;
	h = _tmp5_;
	_tmp6_ = cairo_image_surface_create (CAIRO_FORMAT_RGB24, ((gint) w) + 20, ((gint) h) + 20);
	surface = _tmp6_;
	_tmp7_ = surface;
	_tmp8_ = cairo_create (_tmp7_);
	context = _tmp8_;
	_tmp9_ = mind_map_get_canvas (map);
	_tmp10_ = _tmp9_;
	_tmp11_ = gtk_widget_get_style_context ((GtkWidget*) _tmp10_);
	_tmp12_ = context;
	gtk_render_background (_tmp11_, _tmp12_, (gdouble) 0, (gdouble) 0, (gdouble) (((gint) w) + 20), (gdouble) (((gint) h) + 20));
	_tmp13_ = context;
	cairo_translate (_tmp13_, 10 - x, 10 - y);
	_tmp14_ = mind_map_get_model (map);
	_tmp15_ = _tmp14_;
	_tmp16_ = context;
	map_model_draw_all (_tmp15_, _tmp16_, TRUE, FALSE);
	_tmp17_ = surface;
	_tmp18_ = gdk_pixbuf_get_from_surface (_tmp17_, 0, 0, ((gint) w) + 20, ((gint) h) + 20);
	pixbuf = _tmp18_;
	_tmp19_ = pixbuf;
	_tmp20_ = gdk_pixbuf_add_alpha (_tmp19_, FALSE, (guint8) 0, (guint8) 0, (guint8) 0);
	_g_object_unref0 (pixbuf);
	pixbuf = _tmp20_;
	output_buffer = NULL;
	buffer_size = (gsize) 0;
	_tmp21_ = pixbuf;
	_tmp22_ = gdk_pixbuf_get_pixels (_tmp21_);
	_tmp23_ = pixbuf;
	_tmp24_ = pixbuf;
	_tmp25_ = pixbuf;
	_tmp27_ = WebPEncodeLosslessRGBA (_tmp22_, gdk_pixbuf_get_width (_tmp23_), gdk_pixbuf_get_height (_tmp24_), gdk_pixbuf_get_rowstride (_tmp25_), &_tmp26_);
	output_buffer = _tmp26_;
	buffer_size = _tmp27_;
	if (buffer_size == ((gsize) 0)) {
		FILE* _tmp28_;
		_tmp28_ = stdout;
		fprintf (_tmp28_, "Failed to encode WebP image.\n");
		result = FALSE;
		_g_object_unref0 (pixbuf);
		_cairo_destroy0 (context);
		_cairo_surface_destroy0 (surface);
		return result;
	}
	{
		guint8* obuf = NULL;
		guint8* _tmp29_;
		gint obuf_length1;
		gint _obuf_size_;
		guint8* _tmp34_;
		GFile* file = NULL;
		GFile* _tmp35_;
		GFileOutputStream* output_stream = NULL;
		GFile* _tmp36_;
		GFileOutputStream* _tmp37_;
		GFileOutputStream* _tmp38_;
		guint8* _tmp39_;
		gint _tmp39__length1;
		GFileOutputStream* _tmp41_;
		FILE* _tmp43_;
		_tmp29_ = g_new0 (guint8, 0);
		obuf = _tmp29_;
		obuf_length1 = 0;
		_obuf_size_ = obuf_length1;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp30_ = FALSE;
				_tmp30_ = TRUE;
				while (TRUE) {
					guint8* _tmp32_;
					guint8 _tmp33_;
					if (!_tmp30_) {
						gint _tmp31_;
						_tmp31_ = i;
						i = _tmp31_ + 1;
					}
					_tmp30_ = FALSE;
					if (!(((gsize) i) < buffer_size)) {
						break;
					}
					_tmp32_ = output_buffer;
					_tmp33_ = _tmp32_[i];
					_vala_array_add53 (&obuf, &obuf_length1, &_obuf_size_, _tmp33_);
				}
			}
		}
		_tmp34_ = output_buffer;
		WebPFree (_tmp34_);
		_tmp35_ = g_file_new_for_path (fname);
		file = _tmp35_;
		_tmp36_ = file;
		_tmp37_ = g_file_replace (_tmp36_, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error0_);
		output_stream = _tmp37_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (file);
			obuf = (g_free (obuf), NULL);
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			goto __finally0;
		}
		_tmp38_ = output_stream;
		_tmp39_ = obuf;
		_tmp39__length1 = obuf_length1;
		g_output_stream_write ((GOutputStream*) _tmp38_, _tmp39_, (gsize) _tmp39__length1, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp40_ = FALSE;
			_g_object_unref0 (output_stream);
			_g_object_unref0 (file);
			obuf = (g_free (obuf), NULL);
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			_g_object_unref0 (pixbuf);
			_cairo_destroy0 (context);
			_cairo_surface_destroy0 (surface);
			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 _tmp40_;
		}
		_tmp41_ = output_stream;
		g_output_stream_close ((GOutputStream*) _tmp41_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp42_ = FALSE;
			_g_object_unref0 (output_stream);
			_g_object_unref0 (file);
			obuf = (g_free (obuf), NULL);
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			_g_object_unref0 (pixbuf);
			_cairo_destroy0 (context);
			_cairo_surface_destroy0 (surface);
			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 _tmp42_;
		}
		_tmp43_ = stdout;
		fprintf (_tmp43_, "Successfully exported %s\n", fname);
		_g_object_unref0 (output_stream);
		_g_object_unref0 (file);
		obuf = (g_free (obuf), NULL);
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		GError* e = NULL;
		FILE* _tmp44_;
		GError* _tmp45_;
		const gchar* _tmp46_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp44_ = stdout;
		_tmp45_ = e;
		_tmp46_ = _tmp45_->message;
		fprintf (_tmp44_, "Error saving WebP file: %s", _tmp46_);
		result = FALSE;
		_g_error_free0 (e);
		_g_object_unref0 (pixbuf);
		_cairo_destroy0 (context);
		_cairo_surface_destroy0 (surface);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp47_ = FALSE;
		_g_object_unref0 (pixbuf);
		_cairo_destroy0 (context);
		_cairo_surface_destroy0 (surface);
		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 _tmp47_;
	}
	result = TRUE;
	_g_object_unref0 (pixbuf);
	_cairo_destroy0 (context);
	_cairo_surface_destroy0 (surface);
	return result;
}

static void
export_web_p_class_init (ExportWebPClass * klass,
                         gpointer klass_data)
{
	export_web_p_parent_class = g_type_class_peek_parent (klass);
	((ExportClass *) klass)->export = (gboolean (*) (Export*, const gchar*, MindMap*)) export_web_p_real_export;
}

static void
export_web_p_instance_init (ExportWebP * self,
                            gpointer klass)
{
}

static GType
export_web_p_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ExportWebPClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) export_web_p_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ExportWebP), 0, (GInstanceInitFunc) export_web_p_instance_init, NULL };
	GType export_web_p_type_id;
	export_web_p_type_id = g_type_register_static (TYPE_EXPORT, "ExportWebP", &g_define_type_info, 0);
	return export_web_p_type_id;
}

GType
export_web_p_get_type (void)
{
	static volatile gsize export_web_p_type_id__once = 0;
	if (g_once_init_enter (&export_web_p_type_id__once)) {
		GType export_web_p_type_id;
		export_web_p_type_id = export_web_p_get_type_once ();
		g_once_init_leave (&export_web_p_type_id__once, export_web_p_type_id);
	}
	return export_web_p_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;
}

