iPDC-suite/iPDC/lib/liblivechart.so.p/smooth_line_area.c

565 lines
20 KiB
C

/* smooth_line_area.c generated by valac 0.56.0, the Vala compiler
* generated from smooth_line_area.vala, do not modify */
#include "livechart.h"
#include <glib.h>
#include <float.h>
#include <math.h>
#include <cairo-gobject.h>
#include <gdk/gdk.h>
#include <string.h>
enum {
LIVE_CHART_SMOOTH_LINE_AREA_0_PROPERTY,
LIVE_CHART_SMOOTH_LINE_AREA_AREA_ALPHA_PROPERTY,
LIVE_CHART_SMOOTH_LINE_AREA_NUM_PROPERTIES
};
static GParamSpec* live_chart_smooth_line_area_properties[LIVE_CHART_SMOOTH_LINE_AREA_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _cairo_path_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_path_destroy (var), NULL)))
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
typedef struct _Block5Data Block5Data;
struct _LiveChartSmoothLineAreaPrivate {
gdouble _area_alpha;
};
struct _Block5Data {
int _ref_count_;
LiveChartSmoothLineArea* self;
LiveChartBoundaries boundaries;
cairo_t* ctx;
};
static gint LiveChartSmoothLineArea_private_offset;
static gpointer live_chart_smooth_line_area_parent_class = NULL;
static void live_chart_smooth_line_area_real_draw (LiveChartSerieRenderer* base,
cairo_t* ctx,
LiveChartConfig* config);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static gboolean __lambda14_ (Block5Data* _data5_,
LiveChartIntersection* intersection);
static gboolean ___lambda14__gee_forall_func (gpointer g,
gpointer self);
static void live_chart_smooth_line_area_finalize (GObject * obj);
static GType live_chart_smooth_line_area_get_type_once (void);
static void _vala_live_chart_smooth_line_area_get_property (GObject * object,
guint property_id,
GValue * value,
GParamSpec * pspec);
static void _vala_live_chart_smooth_line_area_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
live_chart_smooth_line_area_get_instance_private (LiveChartSmoothLineArea* self)
{
return G_STRUCT_MEMBER_P (self, LiveChartSmoothLineArea_private_offset);
}
LiveChartSmoothLineArea*
live_chart_smooth_line_area_construct (GType object_type,
LiveChartValues* values)
{
LiveChartSmoothLineArea * self = NULL;
#line 8 "../src/smooth_line_area.vala"
g_return_val_if_fail (values != NULL, NULL);
#line 9 "../src/smooth_line_area.vala"
self = (LiveChartSmoothLineArea*) live_chart_smooth_line_construct (object_type, values);
#line 8 "../src/smooth_line_area.vala"
return self;
#line 77 "smooth_line_area.c"
}
LiveChartSmoothLineArea*
live_chart_smooth_line_area_new (LiveChartValues* values)
{
#line 8 "../src/smooth_line_area.vala"
return live_chart_smooth_line_area_construct (LIVE_CHART_TYPE_SMOOTH_LINE_AREA, values);
#line 85 "smooth_line_area.c"
}
static void
live_chart_smooth_line_area_real_draw (LiveChartSerieRenderer* base,
cairo_t* ctx,
LiveChartConfig* config)
{
LiveChartSmoothLineArea * self;
gboolean _tmp0_;
gboolean _tmp1_;
#line 11 "../src/smooth_line_area.vala"
self = (LiveChartSmoothLineArea*) base;
#line 11 "../src/smooth_line_area.vala"
g_return_if_fail (ctx != NULL);
#line 11 "../src/smooth_line_area.vala"
g_return_if_fail (config != NULL);
#line 12 "../src/smooth_line_area.vala"
_tmp0_ = live_chart_drawable_get_visible ((LiveChartDrawable*) self);
#line 12 "../src/smooth_line_area.vala"
_tmp1_ = _tmp0_;
#line 12 "../src/smooth_line_area.vala"
if (_tmp1_) {
#line 108 "smooth_line_area.c"
LiveChartPoints* points = NULL;
LiveChartValues* _tmp2_;
LiveChartPoints* _tmp3_;
LiveChartPoints* _tmp4_;
gint _tmp5_;
gint _tmp6_;
#line 13 "../src/smooth_line_area.vala"
_tmp2_ = ((LiveChartSerieRenderer*) self)->values;
#line 13 "../src/smooth_line_area.vala"
_tmp3_ = live_chart_points_create (_tmp2_, config);
#line 13 "../src/smooth_line_area.vala"
points = _tmp3_;
#line 14 "../src/smooth_line_area.vala"
_tmp4_ = points;
#line 14 "../src/smooth_line_area.vala"
_tmp5_ = live_chart_points_get_size (_tmp4_);
#line 14 "../src/smooth_line_area.vala"
_tmp6_ = _tmp5_;
#line 14 "../src/smooth_line_area.vala"
if (_tmp6_ > 0) {
#line 129 "smooth_line_area.c"
cairo_path_t* path = NULL;
LiveChartPoints* _tmp7_;
cairo_path_t* _tmp8_;
LiveChartArea* area = NULL;
LiveChartPoints* _tmp9_;
GdkRGBA _tmp10_ = {0};
GdkRGBA _tmp11_;
gdouble _tmp12_;
LiveChartArea* _tmp13_;
LiveChartArea* _tmp14_;
cairo_path_t* _tmp15_;
LiveChartArea* _tmp16_;
#line 16 "../src/smooth_line_area.vala"
cairo_push_group (ctx);
#line 17 "../src/smooth_line_area.vala"
_tmp7_ = points;
#line 17 "../src/smooth_line_area.vala"
_tmp8_ = live_chart_smooth_line_draw_smooth_line ((LiveChartSmoothLine*) self, _tmp7_, ctx, config);
#line 17 "../src/smooth_line_area.vala"
path = _tmp8_;
#line 18 "../src/smooth_line_area.vala"
cairo_stroke_preserve (ctx);
#line 20 "../src/smooth_line_area.vala"
_tmp9_ = points;
#line 20 "../src/smooth_line_area.vala"
live_chart_serie_renderer_get_main_color ((LiveChartSerieRenderer*) self, &_tmp10_);
#line 20 "../src/smooth_line_area.vala"
_tmp11_ = _tmp10_;
#line 20 "../src/smooth_line_area.vala"
_tmp12_ = self->priv->_area_alpha;
#line 20 "../src/smooth_line_area.vala"
_tmp13_ = live_chart_area_new (_tmp9_, &_tmp11_, _tmp12_);
#line 20 "../src/smooth_line_area.vala"
area = _tmp13_;
#line 21 "../src/smooth_line_area.vala"
_tmp14_ = area;
#line 21 "../src/smooth_line_area.vala"
live_chart_drawable_draw ((LiveChartDrawable*) _tmp14_, ctx, config);
#line 22 "../src/smooth_line_area.vala"
cairo_fill (ctx);
#line 24 "../src/smooth_line_area.vala"
cairo_set_operator (ctx, CAIRO_OPERATOR_ATOP);
#line 25 "../src/smooth_line_area.vala"
live_chart_smooth_line_draw_regions_on_line ((LiveChartSmoothLine*) self, ctx, config);
#line 26 "../src/smooth_line_area.vala"
cairo_fill (ctx);
#line 27 "../src/smooth_line_area.vala"
cairo_pop_group_to_source (ctx);
#line 29 "../src/smooth_line_area.vala"
cairo_save (ctx);
#line 30 "../src/smooth_line_area.vala"
_tmp15_ = path;
#line 30 "../src/smooth_line_area.vala"
cairo_append_path (ctx, _tmp15_);
#line 31 "../src/smooth_line_area.vala"
_tmp16_ = area;
#line 31 "../src/smooth_line_area.vala"
live_chart_drawable_draw ((LiveChartDrawable*) _tmp16_, ctx, config);
#line 32 "../src/smooth_line_area.vala"
cairo_clip (ctx);
#line 34 "../src/smooth_line_area.vala"
live_chart_smooth_line_area_draw_regions_on_area (self, ctx, config);
#line 35 "../src/smooth_line_area.vala"
cairo_restore (ctx);
#line 36 "../src/smooth_line_area.vala"
cairo_paint (ctx);
#line 14 "../src/smooth_line_area.vala"
_g_object_unref0 (area);
#line 14 "../src/smooth_line_area.vala"
_cairo_path_destroy0 (path);
#line 200 "smooth_line_area.c"
}
#line 12 "../src/smooth_line_area.vala"
_g_object_unref0 (points);
#line 204 "smooth_line_area.c"
}
}
static gpointer
_cairo_reference0 (gpointer self)
{
#line 42 "../src/smooth_line_area.vala"
return self ? cairo_reference (self) : NULL;
#line 213 "smooth_line_area.c"
}
static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
#line 42 "../src/smooth_line_area.vala"
g_atomic_int_inc (&_data5_->_ref_count_);
#line 42 "../src/smooth_line_area.vala"
return _data5_;
#line 223 "smooth_line_area.c"
}
static void
block5_data_unref (void * _userdata_)
{
Block5Data* _data5_;
_data5_ = (Block5Data*) _userdata_;
#line 42 "../src/smooth_line_area.vala"
if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
#line 233 "smooth_line_area.c"
LiveChartSmoothLineArea* self;
#line 42 "../src/smooth_line_area.vala"
self = _data5_->self;
#line 42 "../src/smooth_line_area.vala"
_cairo_destroy0 (_data5_->ctx);
#line 42 "../src/smooth_line_area.vala"
_g_object_unref0 (self);
#line 42 "../src/smooth_line_area.vala"
g_slice_free (Block5Data, _data5_);
#line 243 "smooth_line_area.c"
}
}
static gboolean
__lambda14_ (Block5Data* _data5_,
LiveChartIntersection* intersection)
{
LiveChartSmoothLineArea* self;
gboolean result;
#line 44 "../src/smooth_line_area.vala"
self = _data5_->self;
#line 45 "../src/smooth_line_area.vala"
if (intersection != NULL) {
#line 257 "smooth_line_area.c"
gdouble _tmp0_;
gdouble _tmp1_;
LiveChartBoundaries _tmp2_;
LiveChartBoundary _tmp3_;
gdouble _tmp4_;
gdouble _tmp5_;
gdouble _tmp6_;
gdouble _tmp7_;
LiveChartBoundaries _tmp8_;
LiveChartRegion* _tmp9_;
LiveChartRegion* _tmp10_;
GdkRGBA _tmp11_ = {0};
GdkRGBA _tmp12_;
LiveChartRegion* _tmp13_;
LiveChartRegion* _tmp14_;
GdkRGBA _tmp15_ = {0};
GdkRGBA _tmp16_;
LiveChartRegion* _tmp17_;
LiveChartRegion* _tmp18_;
GdkRGBA _tmp19_ = {0};
GdkRGBA _tmp20_;
LiveChartRegion* _tmp21_;
LiveChartRegion* _tmp22_;
GdkRGBA _tmp23_ = {0};
GdkRGBA _tmp24_;
#line 46 "../src/smooth_line_area.vala"
_tmp0_ = live_chart_intersection_get_start_x (intersection);
#line 46 "../src/smooth_line_area.vala"
_tmp1_ = _tmp0_;
#line 46 "../src/smooth_line_area.vala"
_tmp2_ = _data5_->boundaries;
#line 46 "../src/smooth_line_area.vala"
_tmp3_ = _tmp2_.y;
#line 46 "../src/smooth_line_area.vala"
_tmp4_ = live_chart_intersection_get_end_x (intersection);
#line 46 "../src/smooth_line_area.vala"
_tmp5_ = _tmp4_;
#line 46 "../src/smooth_line_area.vala"
_tmp6_ = live_chart_intersection_get_start_x (intersection);
#line 46 "../src/smooth_line_area.vala"
_tmp7_ = _tmp6_;
#line 46 "../src/smooth_line_area.vala"
_tmp8_ = _data5_->boundaries;
#line 46 "../src/smooth_line_area.vala"
cairo_rectangle (_data5_->ctx, _tmp1_, (gdouble) _tmp3_.min, _tmp5_ - _tmp7_, (gdouble) _tmp8_.height);
#line 47 "../src/smooth_line_area.vala"
_tmp9_ = live_chart_intersection_get_region (intersection);
#line 47 "../src/smooth_line_area.vala"
_tmp10_ = _tmp9_;
#line 47 "../src/smooth_line_area.vala"
live_chart_region_get_area_color (_tmp10_, &_tmp11_);
#line 47 "../src/smooth_line_area.vala"
_tmp12_ = _tmp11_;
#line 47 "../src/smooth_line_area.vala"
_tmp13_ = live_chart_intersection_get_region (intersection);
#line 47 "../src/smooth_line_area.vala"
_tmp14_ = _tmp13_;
#line 47 "../src/smooth_line_area.vala"
live_chart_region_get_area_color (_tmp14_, &_tmp15_);
#line 47 "../src/smooth_line_area.vala"
_tmp16_ = _tmp15_;
#line 47 "../src/smooth_line_area.vala"
_tmp17_ = live_chart_intersection_get_region (intersection);
#line 47 "../src/smooth_line_area.vala"
_tmp18_ = _tmp17_;
#line 47 "../src/smooth_line_area.vala"
live_chart_region_get_area_color (_tmp18_, &_tmp19_);
#line 47 "../src/smooth_line_area.vala"
_tmp20_ = _tmp19_;
#line 47 "../src/smooth_line_area.vala"
_tmp21_ = live_chart_intersection_get_region (intersection);
#line 47 "../src/smooth_line_area.vala"
_tmp22_ = _tmp21_;
#line 47 "../src/smooth_line_area.vala"
live_chart_region_get_area_color (_tmp22_, &_tmp23_);
#line 47 "../src/smooth_line_area.vala"
_tmp24_ = _tmp23_;
#line 47 "../src/smooth_line_area.vala"
cairo_set_source_rgba (_data5_->ctx, _tmp12_.red, _tmp16_.green, _tmp20_.blue, _tmp24_.alpha);
#line 48 "../src/smooth_line_area.vala"
cairo_fill (_data5_->ctx);
#line 339 "smooth_line_area.c"
}
#line 50 "../src/smooth_line_area.vala"
result = TRUE;
#line 50 "../src/smooth_line_area.vala"
_g_object_unref0 (intersection);
#line 50 "../src/smooth_line_area.vala"
return result;
#line 347 "smooth_line_area.c"
}
static gboolean
___lambda14__gee_forall_func (gpointer g,
gpointer self)
{
gboolean result;
result = __lambda14_ (self, (LiveChartIntersection*) g);
#line 44 "../src/smooth_line_area.vala"
return result;
#line 358 "smooth_line_area.c"
}
void
live_chart_smooth_line_area_draw_regions_on_area (LiveChartSmoothLineArea* self,
cairo_t* ctx,
LiveChartConfig* config)
{
Block5Data* _data5_;
cairo_t* _tmp0_;
LiveChartBoundaries _tmp1_ = {0};
LiveChartIntersections* _tmp2_;
#line 42 "../src/smooth_line_area.vala"
g_return_if_fail (self != NULL);
#line 42 "../src/smooth_line_area.vala"
g_return_if_fail (ctx != NULL);
#line 42 "../src/smooth_line_area.vala"
g_return_if_fail (config != NULL);
#line 42 "../src/smooth_line_area.vala"
_data5_ = g_slice_new0 (Block5Data);
#line 42 "../src/smooth_line_area.vala"
_data5_->_ref_count_ = 1;
#line 42 "../src/smooth_line_area.vala"
_data5_->self = g_object_ref (self);
#line 42 "../src/smooth_line_area.vala"
_tmp0_ = _cairo_reference0 (ctx);
#line 42 "../src/smooth_line_area.vala"
_cairo_destroy0 (_data5_->ctx);
#line 42 "../src/smooth_line_area.vala"
_data5_->ctx = _tmp0_;
#line 43 "../src/smooth_line_area.vala"
live_chart_config_boundaries (config, &_tmp1_);
#line 43 "../src/smooth_line_area.vala"
_data5_->boundaries = _tmp1_;
#line 44 "../src/smooth_line_area.vala"
_tmp2_ = ((LiveChartSmoothLine*) self)->intersections;
#line 44 "../src/smooth_line_area.vala"
live_chart_intersections_foreach (_tmp2_, ___lambda14__gee_forall_func, _data5_);
#line 42 "../src/smooth_line_area.vala"
block5_data_unref (_data5_);
#line 42 "../src/smooth_line_area.vala"
_data5_ = NULL;
#line 400 "smooth_line_area.c"
}
gdouble
live_chart_smooth_line_area_get_area_alpha (LiveChartSmoothLineArea* self)
{
gdouble result;
#line 6 "../src/smooth_line_area.vala"
g_return_val_if_fail (self != NULL, 0.0);
#line 6 "../src/smooth_line_area.vala"
result = self->priv->_area_alpha;
#line 6 "../src/smooth_line_area.vala"
return result;
#line 413 "smooth_line_area.c"
}
void
live_chart_smooth_line_area_set_area_alpha (LiveChartSmoothLineArea* self,
gdouble value)
{
gdouble old_value;
#line 6 "../src/smooth_line_area.vala"
g_return_if_fail (self != NULL);
#line 6 "../src/smooth_line_area.vala"
old_value = live_chart_smooth_line_area_get_area_alpha (self);
#line 6 "../src/smooth_line_area.vala"
if (old_value != value) {
#line 6 "../src/smooth_line_area.vala"
self->priv->_area_alpha = value;
#line 6 "../src/smooth_line_area.vala"
g_object_notify_by_pspec ((GObject *) self, live_chart_smooth_line_area_properties[LIVE_CHART_SMOOTH_LINE_AREA_AREA_ALPHA_PROPERTY]);
#line 431 "smooth_line_area.c"
}
}
static void
live_chart_smooth_line_area_class_init (LiveChartSmoothLineAreaClass * klass,
gpointer klass_data)
{
#line 4 "../src/smooth_line_area.vala"
live_chart_smooth_line_area_parent_class = g_type_class_peek_parent (klass);
#line 4 "../src/smooth_line_area.vala"
g_type_class_adjust_private_offset (klass, &LiveChartSmoothLineArea_private_offset);
#line 4 "../src/smooth_line_area.vala"
((LiveChartSerieRendererClass *) klass)->draw = (void (*) (LiveChartSerieRenderer*, cairo_t*, LiveChartConfig*)) live_chart_smooth_line_area_real_draw;
#line 4 "../src/smooth_line_area.vala"
G_OBJECT_CLASS (klass)->get_property = _vala_live_chart_smooth_line_area_get_property;
#line 4 "../src/smooth_line_area.vala"
G_OBJECT_CLASS (klass)->set_property = _vala_live_chart_smooth_line_area_set_property;
#line 4 "../src/smooth_line_area.vala"
G_OBJECT_CLASS (klass)->finalize = live_chart_smooth_line_area_finalize;
#line 4 "../src/smooth_line_area.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), LIVE_CHART_SMOOTH_LINE_AREA_AREA_ALPHA_PROPERTY, live_chart_smooth_line_area_properties[LIVE_CHART_SMOOTH_LINE_AREA_AREA_ALPHA_PROPERTY] = g_param_spec_double ("area-alpha", "area-alpha", "area-alpha", -G_MAXDOUBLE, G_MAXDOUBLE, 0.1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 453 "smooth_line_area.c"
}
static void
live_chart_smooth_line_area_instance_init (LiveChartSmoothLineArea * self,
gpointer klass)
{
#line 4 "../src/smooth_line_area.vala"
self->priv = live_chart_smooth_line_area_get_instance_private (self);
#line 6 "../src/smooth_line_area.vala"
self->priv->_area_alpha = 0.1;
#line 464 "smooth_line_area.c"
}
static void
live_chart_smooth_line_area_finalize (GObject * obj)
{
LiveChartSmoothLineArea * self;
#line 4 "../src/smooth_line_area.vala"
self = G_TYPE_CHECK_INSTANCE_CAST (obj, LIVE_CHART_TYPE_SMOOTH_LINE_AREA, LiveChartSmoothLineArea);
#line 4 "../src/smooth_line_area.vala"
G_OBJECT_CLASS (live_chart_smooth_line_area_parent_class)->finalize (obj);
#line 475 "smooth_line_area.c"
}
static GType
live_chart_smooth_line_area_get_type_once (void)
{
static const GTypeInfo g_define_type_info = { sizeof (LiveChartSmoothLineAreaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) live_chart_smooth_line_area_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LiveChartSmoothLineArea), 0, (GInstanceInitFunc) live_chart_smooth_line_area_instance_init, NULL };
GType live_chart_smooth_line_area_type_id;
live_chart_smooth_line_area_type_id = g_type_register_static (LIVE_CHART_TYPE_SMOOTH_LINE, "LiveChartSmoothLineArea", &g_define_type_info, 0);
LiveChartSmoothLineArea_private_offset = g_type_add_instance_private (live_chart_smooth_line_area_type_id, sizeof (LiveChartSmoothLineAreaPrivate));
return live_chart_smooth_line_area_type_id;
}
GType
live_chart_smooth_line_area_get_type (void)
{
static volatile gsize live_chart_smooth_line_area_type_id__once = 0;
if (g_once_init_enter (&live_chart_smooth_line_area_type_id__once)) {
GType live_chart_smooth_line_area_type_id;
live_chart_smooth_line_area_type_id = live_chart_smooth_line_area_get_type_once ();
g_once_init_leave (&live_chart_smooth_line_area_type_id__once, live_chart_smooth_line_area_type_id);
}
return live_chart_smooth_line_area_type_id__once;
}
static void
_vala_live_chart_smooth_line_area_get_property (GObject * object,
guint property_id,
GValue * value,
GParamSpec * pspec)
{
LiveChartSmoothLineArea * self;
self = G_TYPE_CHECK_INSTANCE_CAST (object, LIVE_CHART_TYPE_SMOOTH_LINE_AREA, LiveChartSmoothLineArea);
#line 4 "../src/smooth_line_area.vala"
switch (property_id) {
#line 4 "../src/smooth_line_area.vala"
case LIVE_CHART_SMOOTH_LINE_AREA_AREA_ALPHA_PROPERTY:
#line 4 "../src/smooth_line_area.vala"
g_value_set_double (value, live_chart_smooth_line_area_get_area_alpha (self));
#line 4 "../src/smooth_line_area.vala"
break;
#line 516 "smooth_line_area.c"
default:
#line 4 "../src/smooth_line_area.vala"
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 4 "../src/smooth_line_area.vala"
break;
#line 522 "smooth_line_area.c"
}
}
static void
_vala_live_chart_smooth_line_area_set_property (GObject * object,
guint property_id,
const GValue * value,
GParamSpec * pspec)
{
LiveChartSmoothLineArea * self;
self = G_TYPE_CHECK_INSTANCE_CAST (object, LIVE_CHART_TYPE_SMOOTH_LINE_AREA, LiveChartSmoothLineArea);
#line 4 "../src/smooth_line_area.vala"
switch (property_id) {
#line 4 "../src/smooth_line_area.vala"
case LIVE_CHART_SMOOTH_LINE_AREA_AREA_ALPHA_PROPERTY:
#line 4 "../src/smooth_line_area.vala"
live_chart_smooth_line_area_set_area_alpha (self, g_value_get_double (value));
#line 4 "../src/smooth_line_area.vala"
break;
#line 542 "smooth_line_area.c"
default:
#line 4 "../src/smooth_line_area.vala"
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 4 "../src/smooth_line_area.vala"
break;
#line 548 "smooth_line_area.c"
}
}
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;
}