Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/etox
Dir : e17/libs/etox/src
Modified Files:
Etox.h etox_context.c
Log Message:
API addition for copying existing contexts.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/Etox.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- Etox.h 17 Feb 2004 21:58:20 -0000 1.45
+++ Etox.h 28 Feb 2004 04:10:02 -0000 1.46
@@ -101,6 +101,7 @@
Etox_Context *etox_context_new();
Etox_Context *etox_get_context(Evas_Object * et);
void etox_set_context(Evas_Object * et, Etox_Context * context);
+void etox_context_copy(Etox_Context *dst, Etox_Context *src);
Etox_Context *etox_context_save(Evas_Object * et);
void etox_context_load(Evas_Object * et, Etox_Context * context);
void etox_context_free(Etox_Context * context);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_context.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- etox_context.c 17 Feb 2004 21:58:20 -0000 1.17
+++ etox_context.c 28 Feb 2004 04:10:03 -0000 1.18
@@ -51,6 +51,50 @@
}
/**
+ * etox_context_copy - copy the contents of one context into another
+ * @dst: the destination context to receive the contents
+ * @src: the source context that is copied into the destination
+ *
+ * Returns no value. Copies the context data from @src to @dst.
+ */
+void etox_context_copy(Etox_Context *dst, Etox_Context *src)
+{
+
+ CHECK_PARAM_POINTER("dst", dst);
+ CHECK_PARAM_POINTER("src", src);
+
+ /*
+ * Dereference the style before overwriting
+ */
+ IF_FREE(dst->style);
+ IF_FREE(dst->font);
+ IF_FREE(dst->marker.text);
+ IF_FREE(dst->marker.style);
+
+ /*
+ * Copy the contents of the old context
+ */
+ memcpy(dst, src, sizeof(Etox_Context));
+ if (src->style)
+ dst->style = strdup(src->style);
+ else
+ dst->style = NULL;
+
+ if (src->font)
+ dst->font = strdup(src->font);
+
+ if (src->marker.text)
+ dst->marker.text = strdup(src->marker.text);
+
+ if (src->marker.style)
+ dst->marker.style = strdup(src->marker.style);
+
+ dst->flags = src->flags;
+
+ return;
+}
+
+/**
* etox_context_save - save a copy of the current context for restoring later
* @et: the etox to retrieve a copy of the current context
*
@@ -66,24 +110,8 @@
et = evas_object_smart_data_get(obj);
- ret = (Etox_Context *) malloc(sizeof(Etox_Context));
-
- /*
- * Copy the contents of the old context
- */
- memcpy(ret, et->context, sizeof(Etox_Context));
- if (et->context->style)
- ret->style = strdup(et->context->style);
- if (et->context->font)
- ret->font = strdup(et->context->font);
-
- if (et->context->marker.text)
- ret->marker.text = strdup(et->context->marker.text);
-
- if (et->context->marker.style)
- ret->marker.style = strdup(et->context->marker.style);
-
- ret->flags = et->context->flags;
+ ret = (Etox_Context *) calloc(sizeof(Etox_Context), 1);
+ etox_context_copy(ret, et->context);
return ret;
}
@@ -105,28 +133,7 @@
et = evas_object_smart_data_get(obj);
- /*
- * Dereference the style before overwriting
- */
- IF_FREE(et->context->style);
- IF_FREE(et->context->font);
- IF_FREE(et->context->marker.text);
- IF_FREE(et->context->marker.style);
-
- memcpy(et->context, context, sizeof(Etox_Context));
-
- if (context->style)
- et->context->style = strdup(context->style);
- if (context->font)
- et->context->font = strdup(context->font);
-
- if (et->context->marker.text)
- et->context->marker.text = strdup(context->marker.text);
-
- if (et->context->marker.style)
- et->context->marker.style = strdup(context->marker.style);
-
- et->context->flags = context->flags;
+ etox_context_copy(et->context, context);
}
/**
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs