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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "xmpp-vala.h"
#include <glib-object.h>
#include <gee.h>
#include <gobject/gvaluecollector.h>

#define XMPP_ERROR_NS_URI "urn:ietf:params:xml:ns:xmpp-stanzas"
#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

#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
#define _xmpp_error_stanza_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_error_stanza_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _XmppParamSpecErrorStanza XmppParamSpecErrorStanza;

struct _XmppParamSpecErrorStanza {
	GParamSpec parent_instance;
};

static gpointer xmpp_error_stanza_parent_class = NULL;

static void xmpp_error_stanza_finalize (XmppErrorStanza * obj);
static GType xmpp_error_stanza_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

XmppErrorStanza*
xmpp_error_stanza_from_stanza (XmppStanzaNode* stanza)
{
	XmppErrorStanza* error_stanza = NULL;
	XmppErrorStanza* _tmp0_;
	XmppErrorStanza* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppErrorStanza* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppErrorStanza* result;
	g_return_val_if_fail (stanza != NULL, NULL);
	_tmp0_ = xmpp_error_stanza_new ();
	error_stanza = _tmp0_;
	_tmp1_ = error_stanza;
	_tmp2_ = xmpp_stanza_node_get_subnode (stanza, "error", NULL, FALSE);
	_xmpp_stanza_entry_unref0 (_tmp1_->error_node);
	_tmp1_->error_node = _tmp2_;
	_tmp3_ = error_stanza;
	_tmp4_ = _tmp3_->error_node;
	if (_tmp4_ == NULL) {
		result = NULL;
		_xmpp_error_stanza_unref0 (error_stanza);
		return result;
	}
	result = error_stanza;
	return result;
}

XmppErrorStanza*
xmpp_error_stanza_construct_build (GType object_type,
                                   const gchar* type,
                                   const gchar* condition,
                                   const gchar* human_readable,
                                   XmppStanzaNode* application_condition)
{
	XmppErrorStanza* self = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	XmppStanzaNode* _tmp6_;
	XmppStanzaNode* _tmp7_;
	XmppStanzaNode* _tmp8_;
	g_return_val_if_fail (type != NULL, NULL);
	g_return_val_if_fail (condition != NULL, NULL);
	self = (XmppErrorStanza*) g_type_create_instance (object_type);
	_tmp0_ = xmpp_stanza_node_new_build ("error", "jabber:client", NULL, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_stanza_node_put_attribute (_tmp1_, "type", type, NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_stanza_node_new_build (condition, XMPP_ERROR_NS_URI, NULL, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = xmpp_stanza_node_add_self_xmlns (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = xmpp_stanza_node_put_node (_tmp3_, _tmp7_);
	_xmpp_stanza_entry_unref0 (self->error_node);
	self->error_node = _tmp8_;
	_xmpp_stanza_entry_unref0 (_tmp7_);
	_xmpp_stanza_entry_unref0 (_tmp5_);
	_xmpp_stanza_entry_unref0 (_tmp3_);
	_xmpp_stanza_entry_unref0 (_tmp1_);
	if (application_condition != NULL) {
		XmppStanzaNode* _tmp9_;
		XmppStanzaNode* _tmp10_;
		XmppStanzaNode* _tmp11_;
		_tmp9_ = self->error_node;
		_tmp10_ = xmpp_stanza_node_put_node (_tmp9_, application_condition);
		_tmp11_ = _tmp10_;
		_xmpp_stanza_entry_unref0 (_tmp11_);
	}
	if (human_readable != NULL) {
		XmppStanzaNode* _tmp12_;
		XmppStanzaNode* _tmp13_;
		XmppStanzaNode* _tmp14_;
		XmppStanzaNode* _tmp15_;
		XmppStanzaNode* _tmp16_;
		XmppStanzaNode* _tmp17_;
		XmppStanzaNode* _tmp18_;
		XmppStanzaNode* _tmp19_;
		XmppStanzaNode* _tmp20_;
		XmppStanzaNode* _tmp21_;
		XmppStanzaNode* _tmp22_;
		XmppStanzaNode* _tmp23_;
		XmppStanzaNode* _tmp24_;
		_tmp12_ = self->error_node;
		_tmp13_ = xmpp_stanza_node_new_build ("text", XMPP_ERROR_NS_URI, NULL, NULL);
		_tmp14_ = _tmp13_;
		_tmp15_ = xmpp_stanza_node_add_self_xmlns (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = xmpp_stanza_node_put_attribute (_tmp16_, "xml:lang", "en", NULL);
		_tmp18_ = _tmp17_;
		_tmp19_ = xmpp_stanza_node_new_text (human_readable);
		_tmp20_ = _tmp19_;
		_tmp21_ = xmpp_stanza_node_put_node (_tmp18_, _tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = xmpp_stanza_node_put_node (_tmp12_, _tmp22_);
		_tmp24_ = _tmp23_;
		_xmpp_stanza_entry_unref0 (_tmp24_);
		_xmpp_stanza_entry_unref0 (_tmp22_);
		_xmpp_stanza_entry_unref0 (_tmp20_);
		_xmpp_stanza_entry_unref0 (_tmp18_);
		_xmpp_stanza_entry_unref0 (_tmp16_);
		_xmpp_stanza_entry_unref0 (_tmp14_);
	}
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_build (const gchar* type,
                             const gchar* condition,
                             const gchar* human_readable,
                             XmppStanzaNode* application_condition)
{
	return xmpp_error_stanza_construct_build (XMPP_TYPE_ERROR_STANZA, type, condition, human_readable, application_condition);
}

XmppErrorStanza*
xmpp_error_stanza_construct_bad_request (GType object_type,
                                         const gchar* human_readable)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) xmpp_error_stanza_construct_build (object_type, XMPP_ERROR_STANZA_TYPE_MODIFY, XMPP_ERROR_STANZA_CONDITION_BAD_REQUEST, human_readable, NULL);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_bad_request (const gchar* human_readable)
{
	return xmpp_error_stanza_construct_bad_request (XMPP_TYPE_ERROR_STANZA, human_readable);
}

XmppErrorStanza*
xmpp_error_stanza_construct_feature_not_implemented (GType object_type,
                                                     const gchar* human_readable)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) xmpp_error_stanza_construct_build (object_type, XMPP_ERROR_STANZA_TYPE_MODIFY, XMPP_ERROR_STANZA_CONDITION_FEATURE_NOT_IMPLEMENTED, human_readable, NULL);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_feature_not_implemented (const gchar* human_readable)
{
	return xmpp_error_stanza_construct_feature_not_implemented (XMPP_TYPE_ERROR_STANZA, human_readable);
}

XmppErrorStanza*
xmpp_error_stanza_construct_item_not_found (GType object_type,
                                            XmppStanzaNode* application_condition)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) xmpp_error_stanza_construct_build (object_type, XMPP_ERROR_STANZA_TYPE_CANCEL, XMPP_ERROR_STANZA_CONDITION_ITEM_NOT_FOUND, NULL, application_condition);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_item_not_found (XmppStanzaNode* application_condition)
{
	return xmpp_error_stanza_construct_item_not_found (XMPP_TYPE_ERROR_STANZA, application_condition);
}

XmppErrorStanza*
xmpp_error_stanza_construct_not_acceptable (GType object_type,
                                            const gchar* human_readable)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) xmpp_error_stanza_construct_build (object_type, XMPP_ERROR_STANZA_TYPE_MODIFY, XMPP_ERROR_STANZA_CONDITION_NOT_ACCEPTABLE, human_readable, NULL);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_not_acceptable (const gchar* human_readable)
{
	return xmpp_error_stanza_construct_not_acceptable (XMPP_TYPE_ERROR_STANZA, human_readable);
}

XmppErrorStanza*
xmpp_error_stanza_construct_not_allowed (GType object_type,
                                         const gchar* human_readable)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) xmpp_error_stanza_construct_build (object_type, XMPP_ERROR_STANZA_TYPE_CANCEL, XMPP_ERROR_STANZA_CONDITION_NOT_ALLOWED, human_readable, NULL);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_not_allowed (const gchar* human_readable)
{
	return xmpp_error_stanza_construct_not_allowed (XMPP_TYPE_ERROR_STANZA, human_readable);
}

XmppErrorStanza*
xmpp_error_stanza_construct_resource_constraint (GType object_type,
                                                 const gchar* human_readable)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) xmpp_error_stanza_construct_build (object_type, XMPP_ERROR_STANZA_TYPE_WAIT, XMPP_ERROR_STANZA_CONDITION_RESOURCE_CONSTRAINT, human_readable, NULL);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_resource_constraint (const gchar* human_readable)
{
	return xmpp_error_stanza_construct_resource_constraint (XMPP_TYPE_ERROR_STANZA, human_readable);
}

XmppErrorStanza*
xmpp_error_stanza_construct_service_unavailable (GType object_type)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) xmpp_error_stanza_construct_build (object_type, XMPP_ERROR_STANZA_TYPE_CANCEL, XMPP_ERROR_STANZA_CONDITION_SERVICE_UNAVAILABLE, NULL, NULL);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new_service_unavailable (void)
{
	return xmpp_error_stanza_construct_service_unavailable (XMPP_TYPE_ERROR_STANZA);
}

XmppErrorStanza*
xmpp_error_stanza_construct (GType object_type)
{
	XmppErrorStanza* self = NULL;
	self = (XmppErrorStanza*) g_type_create_instance (object_type);
	return self;
}

XmppErrorStanza*
xmpp_error_stanza_new (void)
{
	return xmpp_error_stanza_construct (XMPP_TYPE_ERROR_STANZA);
}

const gchar*
xmpp_error_stanza_get_by (XmppErrorStanza* self)
{
	const gchar* result;
	XmppStanzaNode* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->error_node;
	_tmp1_ = xmpp_stanza_node_get_attribute (_tmp0_, "by", NULL);
	result = _tmp1_;
	return result;
}

const gchar*
xmpp_error_stanza_get_text (XmppErrorStanza* self)
{
	const gchar* result;
	XmppStanzaNode* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->error_node;
	_tmp1_ = xmpp_stanza_node_get_deep_string_content (_tmp0_, XMPP_ERROR_NS_URI ":text", NULL);
	result = _tmp1_;
	return result;
}

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

const gchar*
xmpp_error_stanza_get_condition (XmppErrorStanza* self)
{
	const gchar* result;
	GeeList* subnodes = NULL;
	XmppStanzaNode* _tmp0_;
	GeeList* _tmp1_;
	GeeList* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->error_node;
	_tmp1_ = _tmp0_->sub_nodes;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	subnodes = _tmp2_;
	{
		GeeList* _subnode_list = NULL;
		GeeList* _tmp3_;
		gint _subnode_size = 0;
		GeeList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _subnode_index = 0;
		_tmp3_ = subnodes;
		_subnode_list = _tmp3_;
		_tmp4_ = _subnode_list;
		_tmp5_ = gee_collection_get_size ((GeeCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_subnode_size = _tmp6_;
		_subnode_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			XmppStanzaNode* subnode = NULL;
			GeeList* _tmp9_;
			gpointer _tmp10_;
			XmppStanzaNode* _tmp11_;
			const gchar* _tmp12_;
			_subnode_index = _subnode_index + 1;
			_tmp7_ = _subnode_index;
			_tmp8_ = _subnode_size;
			if (!(_tmp7_ < _tmp8_)) {
				break;
			}
			_tmp9_ = _subnode_list;
			_tmp10_ = gee_list_get (_tmp9_, _subnode_index);
			subnode = (XmppStanzaNode*) _tmp10_;
			_tmp11_ = subnode;
			_tmp12_ = ((XmppStanzaEntry*) _tmp11_)->ns_uri;
			if (g_strcmp0 (_tmp12_, XMPP_ERROR_NS_URI) == 0) {
				XmppStanzaNode* _tmp13_;
				const gchar* _tmp14_;
				_tmp13_ = subnode;
				_tmp14_ = ((XmppStanzaEntry*) _tmp13_)->name;
				result = _tmp14_;
				_xmpp_stanza_entry_unref0 (subnode);
				_g_object_unref0 (subnodes);
				return result;
			}
			_xmpp_stanza_entry_unref0 (subnode);
		}
	}
	result = XMPP_ERROR_STANZA_CONDITION_UNDEFINED_CONDITION;
	_g_object_unref0 (subnodes);
	return result;
}

const gchar*
xmpp_error_stanza_get_type_ (XmppErrorStanza* self)
{
	const gchar* result;
	XmppStanzaNode* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->error_node;
	_tmp1_ = xmpp_stanza_node_get_attribute (_tmp0_, "type", NULL);
	result = _tmp1_;
	return result;
}

static void
xmpp_value_error_stanza_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
xmpp_value_error_stanza_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		xmpp_error_stanza_unref (value->data[0].v_pointer);
	}
}

static void
xmpp_value_error_stanza_copy_value (const GValue* src_value,
                                    GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = xmpp_error_stanza_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
xmpp_value_error_stanza_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
xmpp_value_error_stanza_collect_value (GValue* value,
                                       guint n_collect_values,
                                       GTypeCValue* collect_values,
                                       guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		XmppErrorStanza * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = xmpp_error_stanza_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
xmpp_value_error_stanza_lcopy_value (const GValue* value,
                                     guint n_collect_values,
                                     GTypeCValue* collect_values,
                                     guint collect_flags)
{
	XmppErrorStanza ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = xmpp_error_stanza_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
xmpp_param_spec_error_stanza (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags)
{
	XmppParamSpecErrorStanza* spec;
	g_return_val_if_fail (g_type_is_a (object_type, XMPP_TYPE_ERROR_STANZA), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
xmpp_value_get_error_stanza (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_TYPE_ERROR_STANZA), NULL);
	return value->data[0].v_pointer;
}

void
xmpp_value_set_error_stanza (GValue* value,
                             gpointer v_object)
{
	XmppErrorStanza * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_TYPE_ERROR_STANZA));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_TYPE_ERROR_STANZA));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		xmpp_error_stanza_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_error_stanza_unref (old);
	}
}

void
xmpp_value_take_error_stanza (GValue* value,
                              gpointer v_object)
{
	XmppErrorStanza * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_TYPE_ERROR_STANZA));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_TYPE_ERROR_STANZA));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_error_stanza_unref (old);
	}
}

static void
xmpp_error_stanza_class_init (XmppErrorStanzaClass * klass,
                              gpointer klass_data)
{
	xmpp_error_stanza_parent_class = g_type_class_peek_parent (klass);
	((XmppErrorStanzaClass *) klass)->finalize = xmpp_error_stanza_finalize;
}

static void
xmpp_error_stanza_instance_init (XmppErrorStanza * self,
                                 gpointer klass)
{
	self->ref_count = 1;
}

static void
xmpp_error_stanza_finalize (XmppErrorStanza * obj)
{
	XmppErrorStanza * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_TYPE_ERROR_STANZA, XmppErrorStanza);
	g_signal_handlers_destroy (self);
	_xmpp_stanza_entry_unref0 (self->error_node);
}

static GType
xmpp_error_stanza_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_value_error_stanza_init, xmpp_value_error_stanza_free_value, xmpp_value_error_stanza_copy_value, xmpp_value_error_stanza_peek_pointer, "p", xmpp_value_error_stanza_collect_value, "p", xmpp_value_error_stanza_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppErrorStanzaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_error_stanza_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppErrorStanza), 0, (GInstanceInitFunc) xmpp_error_stanza_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType xmpp_error_stanza_type_id;
	xmpp_error_stanza_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppErrorStanza", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return xmpp_error_stanza_type_id;
}

GType
xmpp_error_stanza_get_type (void)
{
	static volatile gsize xmpp_error_stanza_type_id__once = 0;
	if (g_once_init_enter (&xmpp_error_stanza_type_id__once)) {
		GType xmpp_error_stanza_type_id;
		xmpp_error_stanza_type_id = xmpp_error_stanza_get_type_once ();
		g_once_init_leave (&xmpp_error_stanza_type_id__once, xmpp_error_stanza_type_id);
	}
	return xmpp_error_stanza_type_id__once;
}

gpointer
xmpp_error_stanza_ref (gpointer instance)
{
	XmppErrorStanza * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
xmpp_error_stanza_unref (gpointer instance)
{
	XmppErrorStanza * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_ERROR_STANZA_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

