/* post-processing-pipeline.c generated by valac 0.56.17, the Vala compiler
 * generated from post-processing-pipeline.vala, do not modify */

/*
Peek Copyright (c) 2017 by Philipp Wolfer <ph.wolfer@gmail.com>

This file is part of Peek.

This software is licensed under the GNU General Public License
(version 3 or later). See the LICENSE file in this distribution.
*/

#include "../../application.h"
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.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  {
	PEEK_POST_PROCESSING_POST_PROCESSING_PIPELINE_0_PROPERTY,
	PEEK_POST_PROCESSING_POST_PROCESSING_PIPELINE_NUM_PROPERTIES
};
static GParamSpec* peek_post_processing_post_processing_pipeline_properties[PEEK_POST_PROCESSING_POST_PROCESSING_PIPELINE_NUM_PROPERTIES];
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PeekPostProcessingPostProcessingPipelineProcessAsyncData PeekPostProcessingPostProcessingPipelineProcessAsyncData;

struct _PeekPostProcessingPostProcessingPipelinePrivate {
	GArray* pipeline;
	PeekPostProcessingPostProcessor* active_post_processor;
	gboolean cancelled;
};

struct _PeekPostProcessingPostProcessingPipelineProcessAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PeekPostProcessingPostProcessingPipeline* self;
	GArray* files;
	GArray* result;
	GArray* _tmp0_;
	gpointer* _tmp1_;
	gint _tmp1__length1;
	PeekPostProcessingPostProcessor** post_processor_collection;
	gint post_processor_collection_length1;
	gint _post_processor_collection_size_;
	gint post_processor_it;
	PeekPostProcessingPostProcessor* _tmp2_;
	PeekPostProcessingPostProcessor* post_processor;
	PeekPostProcessingPostProcessor* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	PeekPostProcessingPostProcessor* _tmp7_;
	PeekPostProcessingPostProcessor* _tmp8_;
	GArray* new_files;
	GArray* _tmp9_;
	PeekPostProcessingPostProcessor* _tmp10_;
	GArray* _tmp11_;
	GArray* _tmp12_;
	GError* _inner_error1_;
	gpointer* _tmp13_;
	gint _tmp13__length1;
	GFile** file_collection;
	gint file_collection_length1;
	gint _file_collection_size_;
	gint file_it;
	GFile* _tmp14_;
	GFile* file;
	GFile* _tmp15_;
	GError* e;
	FILE* _tmp16_;
	GFile* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GError* _tmp20_;
	const gchar* _tmp21_;
	GArray* _tmp22_;
	GArray* _tmp23_;
	GArray* _tmp25_;
	GError* _inner_error0_;
};

static gint PeekPostProcessingPostProcessingPipeline_private_offset;
static gpointer peek_post_processing_post_processing_pipeline_parent_class = NULL;
static PeekPostProcessingPostProcessorIface * peek_post_processing_post_processing_pipeline_peek_post_processing_post_processor_parent_iface = NULL;

static void _g_object_unref0_ (gpointer var);
static void _vala_PeekPostProcessingPostProcessor_free_function_content_of (gpointer data);
static void peek_post_processing_post_processing_pipeline_real_process_async_data_free (gpointer _data);
static void peek_post_processing_post_processing_pipeline_real_process_async (PeekPostProcessingPostProcessor* base,
                                                                       GArray* files,
                                                                       GAsyncReadyCallback _callback_,
                                                                       gpointer _user_data_);
static gboolean peek_post_processing_post_processing_pipeline_real_process_async_co (PeekPostProcessingPostProcessingPipelineProcessAsyncData* _data_);
static void peek_post_processing_post_processing_pipeline_process_async_ready (GObject* source_object,
                                                                        GAsyncResult* _res_,
                                                                        gpointer _user_data_);
static void peek_post_processing_post_processing_pipeline_real_cancel (PeekPostProcessingPostProcessor* base);
static void peek_post_processing_post_processing_pipeline_finalize (GObject * obj);
static GType peek_post_processing_post_processing_pipeline_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
peek_post_processing_post_processing_pipeline_get_instance_private (PeekPostProcessingPostProcessingPipeline* self)
{
	return G_STRUCT_MEMBER_P (self, PeekPostProcessingPostProcessingPipeline_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static void
_vala_PeekPostProcessingPostProcessor_free_function_content_of (gpointer data)
{
	PeekPostProcessingPostProcessor* self;
	self = *((PeekPostProcessingPostProcessor**) data);
	_g_object_unref0_ (self);
}

PeekPostProcessingPostProcessingPipeline*
peek_post_processing_post_processing_pipeline_construct (GType object_type)
{
	PeekPostProcessingPostProcessingPipeline * self = NULL;
	GArray* _tmp0_;
	self = (PeekPostProcessingPostProcessingPipeline*) g_object_new (object_type, NULL);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (PeekPostProcessingPostProcessor*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_PeekPostProcessingPostProcessor_free_function_content_of);
	_g_array_unref0 (self->priv->pipeline);
	self->priv->pipeline = _tmp0_;
	return self;
}

PeekPostProcessingPostProcessingPipeline*
peek_post_processing_post_processing_pipeline_new (void)
{
	return peek_post_processing_post_processing_pipeline_construct (PEEK_POST_PROCESSING_TYPE_POST_PROCESSING_PIPELINE);
}

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

void
peek_post_processing_post_processing_pipeline_add (PeekPostProcessingPostProcessingPipeline* self,
                                                   PeekPostProcessingPostProcessor* post_processor)
{
	GArray* _tmp0_;
	PeekPostProcessingPostProcessor* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (post_processor != NULL);
	_tmp0_ = self->priv->pipeline;
	_tmp1_ = _g_object_ref0 (post_processor);
	g_array_append_val (_tmp0_, _tmp1_);
}

static void
peek_post_processing_post_processing_pipeline_real_process_async_data_free (gpointer _data)
{
	PeekPostProcessingPostProcessingPipelineProcessAsyncData* _data_;
	_data_ = _data;
	_g_array_unref0 (_data_->files);
	_g_array_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (PeekPostProcessingPostProcessingPipelineProcessAsyncData, _data_);
}

static gpointer
_g_array_ref0 (gpointer self)
{
	return self ? g_array_ref (self) : NULL;
}

static void
peek_post_processing_post_processing_pipeline_real_process_async (PeekPostProcessingPostProcessor* base,
                                                                  GArray* files,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_)
{
	PeekPostProcessingPostProcessingPipeline * self;
	PeekPostProcessingPostProcessingPipelineProcessAsyncData* _data_;
	PeekPostProcessingPostProcessingPipeline* _tmp0_;
	GArray* _tmp1_;
	g_return_if_fail (files != NULL);
	self = (PeekPostProcessingPostProcessingPipeline*) base;
	_data_ = g_slice_new0 (PeekPostProcessingPostProcessingPipelineProcessAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, peek_post_processing_post_processing_pipeline_real_process_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_array_ref0 (files);
	_g_array_unref0 (_data_->files);
	_data_->files = _tmp1_;
	peek_post_processing_post_processing_pipeline_real_process_async_co (_data_);
}

static GArray*
peek_post_processing_post_processing_pipeline_process_finish (PeekPostProcessingPostProcessor* base,
                                                              GAsyncResult* _res_,
                                                              GError** error)
{
	GArray* result;
	PeekPostProcessingPostProcessingPipelineProcessAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
peek_post_processing_post_processing_pipeline_process_async_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_)
{
	PeekPostProcessingPostProcessingPipelineProcessAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	peek_post_processing_post_processing_pipeline_real_process_async_co (_data_);
}

static gboolean
peek_post_processing_post_processing_pipeline_real_process_async_co (PeekPostProcessingPostProcessingPipelineProcessAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->pipeline;
	_data_->_tmp1_ = _data_->_tmp0_->data;
	_data_->_tmp1__length1 = _data_->_tmp0_->len;
	{
		_data_->post_processor_collection_length1 = 0;
		_data_->_post_processor_collection_size_ = 0;
		_data_->post_processor_collection = _data_->_tmp1_;
		_data_->post_processor_collection_length1 = _data_->_tmp1__length1;
		for (_data_->post_processor_it = 0; _data_->post_processor_it < _data_->post_processor_collection_length1; _data_->post_processor_it = _data_->post_processor_it + 1) {
			_data_->_tmp2_ = _g_object_ref0 (_data_->post_processor_collection[_data_->post_processor_it]);
			_data_->post_processor = _data_->_tmp2_;
			{
				GArray* _tmp24_;
				_data_->_tmp3_ = _data_->post_processor;
				_data_->_tmp4_ = g_type_name (G_TYPE_FROM_INSTANCE ((GObject*) _data_->_tmp3_));
				_data_->_tmp5_ = g_strdup_printf ("%u", _data_->files->len);
				_data_->_tmp6_ = _data_->_tmp5_;
				g_debug ("post-processing-pipeline.vala:30: Running post processor %s with files" \
" %s", _data_->_tmp4_, _data_->_tmp6_);
				_g_free0 (_data_->_tmp6_);
				if (_data_->self->priv->cancelled) {
					_data_->result = NULL;
					_g_object_unref0 (_data_->post_processor);
					g_task_return_pointer (_data_->_async_result, _data_, NULL);
					if (_data_->_state_ != 0) {
						while (!g_task_get_completed (_data_->_async_result)) {
							g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
						}
					}
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->_tmp7_ = _data_->post_processor;
				_data_->_tmp8_ = _g_object_ref0 (_data_->_tmp7_);
				_g_object_unref0 (_data_->self->priv->active_post_processor);
				_data_->self->priv->active_post_processor = _data_->_tmp8_;
				_data_->new_files = NULL;
				{
					_data_->_tmp10_ = _data_->post_processor;
					_data_->_state_ = 1;
					peek_post_processing_post_processor_process_async (_data_->_tmp10_, _data_->files, peek_post_processing_post_processing_pipeline_process_async_ready, _data_);
					return FALSE;
					_state_1:
					_data_->_tmp11_ = peek_post_processing_post_processor_process_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
					_data_->_tmp9_ = _data_->_tmp11_;
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						goto __finally0;
					}
					_data_->_tmp12_ = _data_->_tmp9_;
					_data_->_tmp9_ = NULL;
					_g_array_unref0 (_data_->new_files);
					_data_->new_files = _data_->_tmp12_;
					_g_array_unref0 (_data_->_tmp9_);
				}
				__finally0:
				{
					_data_->_tmp13_ = _data_->files->data;
					_data_->_tmp13__length1 = _data_->files->len;
					{
						_data_->file_collection_length1 = 0;
						_data_->_file_collection_size_ = 0;
						_data_->file_collection = _data_->_tmp13_;
						_data_->file_collection_length1 = _data_->_tmp13__length1;
						for (_data_->file_it = 0; _data_->file_it < _data_->file_collection_length1; _data_->file_it = _data_->file_it + 1) {
							_data_->_tmp14_ = _g_object_ref0 (_data_->file_collection[_data_->file_it]);
							_data_->file = _data_->_tmp14_;
							{
								{
									_data_->_tmp15_ = _data_->file;
									_data_->_state_ = 2;
									g_file_delete_async (_data_->_tmp15_, G_PRIORITY_DEFAULT, NULL, peek_post_processing_post_processing_pipeline_process_async_ready, _data_);
									return FALSE;
									_state_2:
									g_file_delete_finish (_data_->_tmp15_, _data_->_res_, &_data_->_inner_error1_);
									if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
										goto __catch1_g_error;
									}
								}
								goto __finally1;
								__catch1_g_error:
								{
									_data_->e = _data_->_inner_error1_;
									_data_->_inner_error1_ = NULL;
									_data_->_tmp16_ = stderr;
									_data_->_tmp17_ = _data_->file;
									_data_->_tmp18_ = g_file_get_path (_data_->_tmp17_);
									_data_->_tmp19_ = _data_->_tmp18_;
									_data_->_tmp20_ = _data_->e;
									_data_->_tmp21_ = _data_->_tmp20_->message;
									fprintf (_data_->_tmp16_, "Error deleting temporary file %s: %s\n", _data_->_tmp19_, _data_->_tmp21_);
									_g_free0 (_data_->_tmp19_);
									_g_error_free0 (_data_->e);
								}
								__finally1:
								if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
									if (_data_->_inner_error1_->domain == PEEK_RECORDING_ERROR) {
										g_task_return_error (_data_->_async_result, _data_->_inner_error1_);
										_g_object_unref0 (_data_->file);
										_g_array_unref0 (_data_->new_files);
										_g_object_unref0 (_data_->post_processor);
										g_object_unref (_data_->_async_result);
										return FALSE;
									} else {
										_g_object_unref0 (_data_->file);
										_g_array_unref0 (_data_->new_files);
										_g_object_unref0 (_data_->post_processor);
										g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error1_->message, g_quark_to_string (_data_->_inner_error1_->domain), _data_->_inner_error1_->code);
										g_clear_error (&_data_->_inner_error1_);
										g_object_unref (_data_->_async_result);
										return FALSE;
									}
								}
								_g_object_unref0 (_data_->file);
							}
						}
					}
				}
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					if (_data_->_inner_error0_->domain == PEEK_RECORDING_ERROR) {
						g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
						_g_array_unref0 (_data_->new_files);
						_g_object_unref0 (_data_->post_processor);
						g_object_unref (_data_->_async_result);
						return FALSE;
					} else {
						_g_array_unref0 (_data_->new_files);
						_g_object_unref0 (_data_->post_processor);
						g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
						g_clear_error (&_data_->_inner_error0_);
						g_object_unref (_data_->_async_result);
						return FALSE;
					}
				}
				_data_->_tmp22_ = _data_->new_files;
				if (_data_->_tmp22_ == NULL) {
					_data_->self->priv->cancelled = TRUE;
					_g_object_unref0 (_data_->self->priv->active_post_processor);
					_data_->self->priv->active_post_processor = NULL;
					_data_->result = NULL;
					_g_array_unref0 (_data_->new_files);
					_g_object_unref0 (_data_->post_processor);
					g_task_return_pointer (_data_->_async_result, _data_, NULL);
					if (_data_->_state_ != 0) {
						while (!g_task_get_completed (_data_->_async_result)) {
							g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
						}
					}
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->_tmp23_ = _data_->new_files;
				_tmp24_ = _g_array_ref0 (_data_->_tmp23_);
				_g_array_unref0 (_data_->files);
				_data_->files = _tmp24_;
				_g_array_unref0 (_data_->new_files);
				_g_object_unref0 (_data_->post_processor);
			}
		}
	}
	_g_object_unref0 (_data_->self->priv->active_post_processor);
	_data_->self->priv->active_post_processor = NULL;
	_data_->_tmp25_ = _g_array_ref0 (_data_->files);
	_data_->result = _data_->_tmp25_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
peek_post_processing_post_processing_pipeline_real_cancel (PeekPostProcessingPostProcessor* base)
{
	PeekPostProcessingPostProcessingPipeline * self;
	gboolean _tmp0_ = FALSE;
	PeekPostProcessingPostProcessor* _tmp1_;
	self = (PeekPostProcessingPostProcessingPipeline*) base;
	_tmp1_ = self->priv->active_post_processor;
	if (_tmp1_ != NULL) {
		_tmp0_ = !self->priv->cancelled;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		PeekPostProcessingPostProcessor* _tmp2_;
		self->priv->cancelled = TRUE;
		_tmp2_ = self->priv->active_post_processor;
		peek_post_processing_post_processor_cancel (_tmp2_);
		_g_object_unref0 (self->priv->active_post_processor);
		self->priv->active_post_processor = NULL;
	}
}

static void
peek_post_processing_post_processing_pipeline_class_init (PeekPostProcessingPostProcessingPipelineClass * klass,
                                                          gpointer klass_data)
{
	peek_post_processing_post_processing_pipeline_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PeekPostProcessingPostProcessingPipeline_private_offset);
	G_OBJECT_CLASS (klass)->finalize = peek_post_processing_post_processing_pipeline_finalize;
}

static void
peek_post_processing_post_processing_pipeline_peek_post_processing_post_processor_interface_init (PeekPostProcessingPostProcessorIface * iface,
                                                                                                  gpointer iface_data)
{
	peek_post_processing_post_processing_pipeline_peek_post_processing_post_processor_parent_iface = g_type_interface_peek_parent (iface);
	iface->process_async = (void (*) (PeekPostProcessingPostProcessor*, GArray*, GAsyncReadyCallback, gpointer)) peek_post_processing_post_processing_pipeline_real_process_async;
	iface->process_finish = (GArray* (*) (PeekPostProcessingPostProcessor*, GAsyncResult*, GError**)) peek_post_processing_post_processing_pipeline_process_finish;
	iface->cancel = (void (*) (PeekPostProcessingPostProcessor*)) peek_post_processing_post_processing_pipeline_real_cancel;
}

static void
peek_post_processing_post_processing_pipeline_instance_init (PeekPostProcessingPostProcessingPipeline * self,
                                                             gpointer klass)
{
	self->priv = peek_post_processing_post_processing_pipeline_get_instance_private (self);
	self->priv->active_post_processor = NULL;
	self->priv->cancelled = FALSE;
}

static void
peek_post_processing_post_processing_pipeline_finalize (GObject * obj)
{
	PeekPostProcessingPostProcessingPipeline * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PEEK_POST_PROCESSING_TYPE_POST_PROCESSING_PIPELINE, PeekPostProcessingPostProcessingPipeline);
	_g_array_unref0 (self->priv->pipeline);
	_g_object_unref0 (self->priv->active_post_processor);
	G_OBJECT_CLASS (peek_post_processing_post_processing_pipeline_parent_class)->finalize (obj);
}

/**
  * Uses ffmpeg to generate PNG images for each frame.
  */
static GType
peek_post_processing_post_processing_pipeline_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PeekPostProcessingPostProcessingPipelineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) peek_post_processing_post_processing_pipeline_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PeekPostProcessingPostProcessingPipeline), 0, (GInstanceInitFunc) peek_post_processing_post_processing_pipeline_instance_init, NULL };
	static const GInterfaceInfo peek_post_processing_post_processor_info = { (GInterfaceInitFunc) peek_post_processing_post_processing_pipeline_peek_post_processing_post_processor_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType peek_post_processing_post_processing_pipeline_type_id;
	peek_post_processing_post_processing_pipeline_type_id = g_type_register_static (G_TYPE_OBJECT, "PeekPostProcessingPostProcessingPipeline", &g_define_type_info, 0);
	g_type_add_interface_static (peek_post_processing_post_processing_pipeline_type_id, PEEK_POST_PROCESSING_TYPE_POST_PROCESSOR, &peek_post_processing_post_processor_info);
	PeekPostProcessingPostProcessingPipeline_private_offset = g_type_add_instance_private (peek_post_processing_post_processing_pipeline_type_id, sizeof (PeekPostProcessingPostProcessingPipelinePrivate));
	return peek_post_processing_post_processing_pipeline_type_id;
}

GType
peek_post_processing_post_processing_pipeline_get_type (void)
{
	static volatile gsize peek_post_processing_post_processing_pipeline_type_id__once = 0;
	if (g_once_init_enter (&peek_post_processing_post_processing_pipeline_type_id__once)) {
		GType peek_post_processing_post_processing_pipeline_type_id;
		peek_post_processing_post_processing_pipeline_type_id = peek_post_processing_post_processing_pipeline_get_type_once ();
		g_once_init_leave (&peek_post_processing_post_processing_pipeline_type_id__once, peek_post_processing_post_processing_pipeline_type_id);
	}
	return peek_post_processing_post_processing_pipeline_type_id__once;
}

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

