/* log-scale-row.c generated by valac 0.56.19, the Vala compiler
 * generated from log-scale-row.vala, do not modify */

/*
 * Copyright (c) 2023-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include "ft_ui.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <math.h>
#include <float.h>
#include "ft_core.h"
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.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  {
	FT_LOG_SCALE_ROW_0_PROPERTY,
	FT_LOG_SCALE_ROW_ADJUSTMENT_PROPERTY,
	FT_LOG_SCALE_ROW_NUM_PROPERTIES
};
static GParamSpec* ft_log_scale_row_properties[FT_LOG_SCALE_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	FT_LOG_SCALE_ROW_VALUE_CHANGED_SIGNAL,
	FT_LOG_SCALE_ROW_NUM_SIGNALS
};
static guint ft_log_scale_row_signals[FT_LOG_SCALE_ROW_NUM_SIGNALS] = {0};

struct _FtLogScaleRowPrivate {
	GtkLabel* title_label;
	GtkLabel* value_label;
	FtLogScale* scale;
	GtkAdjustment* _adjustment;
	gboolean pending_value_changed;
};

static gint FtLogScaleRow_private_offset;
static gpointer ft_log_scale_row_parent_class = NULL;

static void ft_log_scale_row_value_changed (FtLogScaleRow* self);
static void ft_log_scale_row_update_value_label (FtLogScaleRow* self);
static void ft_log_scale_row_on_value_changed (FtLogScaleRow* self);
static gboolean ft_log_scale_row_on_scroll (FtLogScaleRow* self,
                                     gdouble dx,
                                     gdouble dy);
static gboolean ft_log_scale_row_on_key_pressed (FtLogScaleRow* self,
                                          guint keyval,
                                          guint keycode,
                                          GdkModifierType state);
static void ft_log_scale_row_on_notify_css_classes (FtLogScaleRow* self);
static void _ft_log_scale_row_on_notify_css_classes_g_object_notify (GObject* _sender,
                                                              GParamSpec* pspec,
                                                              gpointer self);
static gboolean ft_log_scale_row_real_focus (GtkWidget* base,
                                      GtkDirectionType direction);
static void ft_log_scale_row_real_dispose (GObject* base);
static void _ft_log_scale_row_on_value_changed_gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                                                      gpointer self);
static GObject * ft_log_scale_row_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static gboolean _ft_log_scale_row_on_scroll_gtk_event_controller_scroll_scroll (GtkEventControllerScroll* _sender,
                                                                         gdouble dx,
                                                                         gdouble dy,
                                                                         gpointer self);
static gboolean _ft_log_scale_row_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                guint keyval,
                                                                                guint keycode,
                                                                                GdkModifierType state,
                                                                                gpointer self);
static void ft_log_scale_row_finalize (GObject * obj);
static GType ft_log_scale_row_get_type_once (void);
static void _vala_ft_log_scale_row_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_ft_log_scale_row_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_log_scale_row_get_instance_private (FtLogScaleRow* self)
{
	return G_STRUCT_MEMBER_P (self, FtLogScaleRow_private_offset);
}

static void
ft_log_scale_row_update_value_label (FtLogScaleRow* self)
{
	GtkAdjustment* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_adjustment;
	if (_tmp0_ != NULL) {
		gint seconds = 0;
		GtkAdjustment* _tmp1_;
		gdouble _tmp2_;
		gdouble _tmp3_;
		GtkLabel* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp1_ = self->priv->_adjustment;
		_tmp2_ = gtk_adjustment_get_value (_tmp1_);
		_tmp3_ = _tmp2_;
		seconds = (gint) CLAMP (round (_tmp3_), (gdouble) 0, (gdouble) G_MAXINT);
		_tmp4_ = self->priv->value_label;
		_tmp5_ = ft_format_time ((guint) seconds);
		_tmp6_ = _tmp5_;
		gtk_label_set_label (_tmp4_, _tmp6_);
		_g_free0 (_tmp6_);
	}
}

static void
ft_log_scale_row_on_value_changed (FtLogScaleRow* self)
{
	FtLogScale* _tmp0_;
	g_return_if_fail (self != NULL);
	ft_log_scale_row_update_value_label (self);
	_tmp0_ = self->priv->scale;
	if (gtk_widget_has_css_class ((GtkWidget*) _tmp0_, "dragging")) {
		self->priv->pending_value_changed = TRUE;
	} else {
		g_signal_emit (self, ft_log_scale_row_signals[FT_LOG_SCALE_ROW_VALUE_CHANGED_SIGNAL], 0);
	}
}

static gboolean
ft_log_scale_row_on_scroll (FtLogScaleRow* self,
                            gdouble dx,
                            gdouble dy)
{
	gboolean _tmp0_ = FALSE;
	GtkAdjustment* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->_adjustment;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = dy == 0.0;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	if (dy < 0.0) {
		FtLogScale* _tmp2_;
		_tmp2_ = self->priv->scale;
		ft_log_scale_step_forward (_tmp2_);
	} else {
		FtLogScale* _tmp3_;
		_tmp3_ = self->priv->scale;
		ft_log_scale_step_backward (_tmp3_);
	}
	result = TRUE;
	return result;
}

static gboolean
ft_log_scale_row_on_key_pressed (FtLogScaleRow* self,
                                 guint keyval,
                                 guint keycode,
                                 GdkModifierType state)
{
	GtkAdjustment* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_adjustment;
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	switch (keyval) {
		case GDK_KEY_Page_Up:
		{
			FtLogScale* _tmp1_;
			_tmp1_ = self->priv->scale;
			ft_log_scale_step_forward (_tmp1_);
			result = TRUE;
			return result;
		}
		case GDK_KEY_Page_Down:
		{
			FtLogScale* _tmp2_;
			_tmp2_ = self->priv->scale;
			ft_log_scale_step_backward (_tmp2_);
			result = TRUE;
			return result;
		}
		default:
		{
			result = FALSE;
			return result;
		}
	}
}

static void
ft_log_scale_row_on_notify_css_classes (FtLogScaleRow* self)
{
	gboolean is_dragging = FALSE;
	FtLogScale* _tmp0_;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->scale;
	is_dragging = gtk_widget_has_css_class ((GtkWidget*) _tmp0_, "dragging");
	if (self->priv->pending_value_changed) {
		_tmp1_ = !is_dragging;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		g_signal_emit (self, ft_log_scale_row_signals[FT_LOG_SCALE_ROW_VALUE_CHANGED_SIGNAL], 0);
	}
}

static void
_ft_log_scale_row_on_notify_css_classes_g_object_notify (GObject* _sender,
                                                         GParamSpec* pspec,
                                                         gpointer self)
{
	ft_log_scale_row_on_notify_css_classes ((FtLogScaleRow*) self);
}

static gboolean
ft_log_scale_row_real_focus (GtkWidget* base,
                             GtkDirectionType direction)
{
	FtLogScaleRow * self;
	gboolean result;
	self = (FtLogScaleRow*) base;
	if (gtk_widget_is_focus ((GtkWidget*) self)) {
		result = FALSE;
		return result;
	}
	gtk_widget_grab_focus ((GtkWidget*) self);
	result = TRUE;
	return result;
}

static void
_ft_log_scale_row_on_value_changed_gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                                                 gpointer self)
{
	ft_log_scale_row_on_value_changed ((FtLogScaleRow*) self);
}

static void
ft_log_scale_row_real_dispose (GObject* base)
{
	FtLogScaleRow * self;
	GtkAdjustment* _tmp0_;
	self = (FtLogScaleRow*) base;
	_tmp0_ = self->priv->_adjustment;
	if (_tmp0_ != NULL) {
		GtkAdjustment* _tmp1_;
		guint _tmp2_;
		_tmp1_ = self->priv->_adjustment;
		g_signal_parse_name ("value-changed", gtk_adjustment_get_type (), &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_log_scale_row_on_value_changed_gtk_adjustment_value_changed, self);
		_g_object_unref0 (self->priv->_adjustment);
		self->priv->_adjustment = NULL;
	}
	G_OBJECT_CLASS (ft_log_scale_row_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_action_row_get_type (), AdwActionRow));
}

FtLogScaleRow*
ft_log_scale_row_construct (GType object_type)
{
	FtLogScaleRow * self = NULL;
	self = (FtLogScaleRow*) g_object_new (object_type, NULL);
	return self;
}

FtLogScaleRow*
ft_log_scale_row_new (void)
{
	return ft_log_scale_row_construct (FT_TYPE_LOG_SCALE_ROW);
}

GtkAdjustment*
ft_log_scale_row_get_adjustment (FtLogScaleRow* self)
{
	GtkAdjustment* result;
	GtkAdjustment* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_adjustment;
	result = _tmp0_;
	return result;
}

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

void
ft_log_scale_row_set_adjustment (FtLogScaleRow* self,
                                 GtkAdjustment* value)
{
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp3_;
	GtkAdjustment* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_adjustment;
	if (_tmp0_ != NULL) {
		GtkAdjustment* _tmp1_;
		guint _tmp2_;
		_tmp1_ = self->priv->_adjustment;
		g_signal_parse_name ("value-changed", gtk_adjustment_get_type (), &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_log_scale_row_on_value_changed_gtk_adjustment_value_changed, self);
	}
	_tmp3_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_adjustment);
	self->priv->_adjustment = _tmp3_;
	g_signal_emit (self, ft_log_scale_row_signals[FT_LOG_SCALE_ROW_VALUE_CHANGED_SIGNAL], 0);
	ft_log_scale_row_update_value_label (self);
	_tmp4_ = self->priv->_adjustment;
	if (_tmp4_ != NULL) {
		GtkAdjustment* _tmp5_;
		_tmp5_ = self->priv->_adjustment;
		g_signal_connect_object (_tmp5_, "value-changed", (GCallback) _ft_log_scale_row_on_value_changed_gtk_adjustment_value_changed, self, 0);
	}
	g_object_notify_by_pspec ((GObject *) self, ft_log_scale_row_properties[FT_LOG_SCALE_ROW_ADJUSTMENT_PROPERTY]);
}

static void
ft_log_scale_row_real_value_changed (FtLogScaleRow* self)
{
	g_return_if_fail (self != NULL);
	self->priv->pending_value_changed = FALSE;
}

static gboolean
_ft_log_scale_row_on_scroll_gtk_event_controller_scroll_scroll (GtkEventControllerScroll* _sender,
                                                                gdouble dx,
                                                                gdouble dy,
                                                                gpointer self)
{
	gboolean result;
	result = ft_log_scale_row_on_scroll ((FtLogScaleRow*) self, dx, dy);
	return result;
}

static gboolean
_ft_log_scale_row_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                       guint keyval,
                                                                       guint keycode,
                                                                       GdkModifierType state,
                                                                       gpointer self)
{
	gboolean result;
	result = ft_log_scale_row_on_key_pressed ((FtLogScaleRow*) self, keyval, keycode, state);
	return result;
}

static GObject *
ft_log_scale_row_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtLogScaleRow * self;
	GtkLabel* _tmp0_;
	FtLogScale* _tmp1_;
	GtkEventControllerScroll* scroll_controller = NULL;
	GtkEventControllerScroll* _tmp2_;
	GtkEventControllerScroll* _tmp3_;
	GtkEventControllerScroll* _tmp4_;
	GtkEventControllerScroll* _tmp5_;
	GtkEventController* _tmp6_;
	GtkEventControllerKey* key_controller = NULL;
	GtkEventControllerKey* _tmp7_;
	GtkEventControllerKey* _tmp8_;
	GtkEventControllerKey* _tmp9_;
	GtkEventController* _tmp10_;
	parent_class = G_OBJECT_CLASS (ft_log_scale_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_LOG_SCALE_ROW, FtLogScaleRow);
	_tmp0_ = self->priv->title_label;
	g_object_bind_property_with_closures ((GObject*) self, "title", (GObject*) _tmp0_, "label", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp1_ = self->priv->scale;
	g_object_bind_property_with_closures ((GObject*) self, "adjustment", (GObject*) _tmp1_, "adjustment", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp2_ = (GtkEventControllerScroll*) gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL);
	scroll_controller = _tmp2_;
	_tmp3_ = scroll_controller;
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _tmp3_, GTK_PHASE_CAPTURE);
	_tmp4_ = scroll_controller;
	g_signal_connect_object (_tmp4_, "scroll", (GCallback) _ft_log_scale_row_on_scroll_gtk_event_controller_scroll_scroll, self, 0);
	_tmp5_ = scroll_controller;
	_tmp6_ = _g_object_ref0 ((GtkEventController*) _tmp5_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp6_);
	_tmp7_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	key_controller = _tmp7_;
	_tmp8_ = key_controller;
	g_signal_connect_object (_tmp8_, "key-pressed", (GCallback) _ft_log_scale_row_on_key_pressed_gtk_event_controller_key_key_pressed, self, 0);
	_tmp9_ = key_controller;
	_tmp10_ = _g_object_ref0 ((GtkEventController*) _tmp9_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp10_);
	ft_log_scale_row_update_value_label (self);
	_g_object_unref0 (key_controller);
	_g_object_unref0 (scroll_controller);
	return obj;
}

static void
ft_log_scale_row_class_init (FtLogScaleRowClass * klass,
                             gpointer klass_data)
{
	ft_log_scale_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtLogScaleRow_private_offset);
	((GtkWidgetClass *) klass)->focus = (gboolean (*) (GtkWidget*, GtkDirectionType)) ft_log_scale_row_real_focus;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_log_scale_row_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_log_scale_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_log_scale_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_log_scale_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_log_scale_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_LOG_SCALE_ROW_ADJUSTMENT_PROPERTY, ft_log_scale_row_properties[FT_LOG_SCALE_ROW_ADJUSTMENT_PROPERTY] = g_param_spec_object ("adjustment", "adjustment", "adjustment", gtk_adjustment_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/preferences/timer/widgets/log-scale-row.ui");
	/**
	         * Emitted when user stops dragging the slider unlike `notify["value"]` on the
	         * `Gtk.Adjustment`.
	         */
	ft_log_scale_row_signals[FT_LOG_SCALE_ROW_VALUE_CHANGED_SIGNAL] = g_signal_new_class_handler ("value-changed", FT_TYPE_LOG_SCALE_ROW, G_SIGNAL_RUN_LAST, (GCallback) ft_log_scale_row_real_value_changed, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "title_label", FALSE, FtLogScaleRow_private_offset + G_STRUCT_OFFSET (FtLogScaleRowPrivate, title_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "value_label", FALSE, FtLogScaleRow_private_offset + G_STRUCT_OFFSET (FtLogScaleRowPrivate, value_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "scale", FALSE, FtLogScaleRow_private_offset + G_STRUCT_OFFSET (FtLogScaleRowPrivate, scale));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_notify_css_classes", G_CALLBACK(_ft_log_scale_row_on_notify_css_classes_g_object_notify));
}

static void
ft_log_scale_row_instance_init (FtLogScaleRow * self,
                                gpointer klass)
{
	self->priv = ft_log_scale_row_get_instance_private (self);
	self->priv->pending_value_changed = FALSE;
	g_type_ensure (FT_TYPE_LOG_SCALE);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_log_scale_row_finalize (GObject * obj)
{
	FtLogScaleRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_LOG_SCALE_ROW, FtLogScaleRow);
	_g_object_unref0 (self->priv->_adjustment);
	G_OBJECT_CLASS (ft_log_scale_row_parent_class)->finalize (obj);
}

static GType
ft_log_scale_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtLogScaleRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_log_scale_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtLogScaleRow), 0, (GInstanceInitFunc) ft_log_scale_row_instance_init, NULL };
	GType ft_log_scale_row_type_id;
	ft_log_scale_row_type_id = g_type_register_static (adw_action_row_get_type (), "FtLogScaleRow", &g_define_type_info, 0);
	FtLogScaleRow_private_offset = g_type_add_instance_private (ft_log_scale_row_type_id, sizeof (FtLogScaleRowPrivate));
	return ft_log_scale_row_type_id;
}

GType
ft_log_scale_row_get_type (void)
{
	static volatile gsize ft_log_scale_row_type_id__once = 0;
	if (g_once_init_enter (&ft_log_scale_row_type_id__once)) {
		GType ft_log_scale_row_type_id;
		ft_log_scale_row_type_id = ft_log_scale_row_get_type_once ();
		g_once_init_leave (&ft_log_scale_row_type_id__once, ft_log_scale_row_type_id);
	}
	return ft_log_scale_row_type_id__once;
}

static void
_vala_ft_log_scale_row_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	FtLogScaleRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_LOG_SCALE_ROW, FtLogScaleRow);
	switch (property_id) {
		case FT_LOG_SCALE_ROW_ADJUSTMENT_PROPERTY:
		g_value_set_object (value, ft_log_scale_row_get_adjustment (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_log_scale_row_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	FtLogScaleRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_LOG_SCALE_ROW, FtLogScaleRow);
	switch (property_id) {
		case FT_LOG_SCALE_ROW_ADJUSTMENT_PROPERTY:
		ft_log_scale_row_set_adjustment (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

