Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/etox

Dir     : e17/libs/etox/src/style


Modified Files:
        Etox_Style.h etox_style.c etox_style_style.c 
        etox_style_style.h 


Log Message:
Move towards using a garbage collecting scheme for freeing style info.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/style/Etox_Style.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- Etox_Style.h        6 May 2004 05:17:52 -0000       1.1
+++ Etox_Style.h        29 Jul 2004 19:46:40 -0000      1.2
@@ -16,6 +16,7 @@
  * Constructor/destructor
  */
 Evas_Object *etox_style_new(Evas *evas, char *text, char *style);
+void etox_style_gc_collect();
 
 /*
  * Content and appearance manipulators
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/style/etox_style.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etox_style.c        11 Jun 2004 14:19:05 -0000      1.2
+++ etox_style.c        29 Jul 2004 19:46:40 -0000      1.3
@@ -118,6 +118,16 @@
 }
 
 /**
+ * etox_style_gc_collect - run through and free up cached styles
+ *
+ * Returns no value.
+ */
+void etox_style_gc_collect()
+{
+       _etox_style_style_info_collect();
+}
+
+/**
  * etox_style_show - display an etox_style or any changes made to a etox_style
  * @etox_style: the etox_style that needs display updates
  *
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/style/etox_style_style.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- etox_style_style.c  25 Jul 2004 14:44:15 -0000      1.4
+++ etox_style_style.c  29 Jul 2004 19:46:40 -0000      1.5
@@ -4,6 +4,7 @@
 #define SET_REL_COLOR(a, b) ((a + b) > 255 ? 255 : ((a + b) < 0 ? 0 : a + b))
 
 static Ecore_Hash *styles = NULL;
+static Evas_List *gc = NULL;
 static int style_path = 0;
 
 static void __etox_style_style_read(Etox_Style_Style_Info * info);
@@ -566,7 +567,11 @@
                 */
                found->name = ecore_string_instance(name);
                __etox_style_style_info_load(found);
-               ecore_hash_set(styles, name, found);
+               ecore_hash_set(styles, strdup(name), found);
+       }
+       else {
+               if (evas_list_find(gc, found))
+                       gc = evas_list_remove(gc, found);
        }
 
        found->references++;
@@ -582,12 +587,21 @@
 {
        info->references--;
 
+       if (info->references < 1 && !evas_list_find(gc, info))
+               gc = evas_list_append(gc, info);
+}
+
+void _etox_style_style_info_collect()
+{
        /*
         * If there are no more references to the style, then we can remove
         * the info from the hash table and free up some memory.
         */
-       if (info->references < 1) {
+       while (gc) {
+               Etox_Style_Style_Info *info;
 
+               info = gc->data;
+               gc = evas_list_remove(gc, info);
                ecore_hash_remove(styles, info->name);
                if (info->layers)
                        _etox_style_heap_destroy(info->layers);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/style/etox_style_style.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etox_style_style.h  6 May 2004 05:17:52 -0000       1.1
+++ etox_style_style.h  29 Jul 2004 19:46:40 -0000      1.2
@@ -47,6 +47,7 @@
  */
 Etox_Style_Style *_etox_style_style_instance(char *name);
 void _etox_style_style_release(Etox_Style_Style * style, Evas *ev);
+void _etox_style_style_info_collect();
 
 /*
  * Style display modifiers.




-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to