gobjects referenced in attributes. No more recursive_free
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 24 Jun 2004 19:13:42 +0000 (19:13 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 24 Jun 2004 19:13:42 +0000 (19:13 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@611 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/attribute.c
ltt/branches/poly/lttv/lttv/attribute.h
ltt/branches/poly/lttv/lttv/iattribute.c
ltt/branches/poly/lttv/lttv/iattribute.h
ltt/branches/poly/lttv/lttv/state.c
ltt/branches/poly/lttv/lttv/stats.c

index a862cdf78ec094a9fe015b539d41c0221fdae09c..db6fa6a6396ace93e02f2140db03022d1b719ac2 100644 (file)
@@ -161,6 +161,10 @@ lttv_attribute_remove(LttvAttribute *self, unsigned i)
 
   a = &g_array_index(self->attributes, Attribute, i);
 
+  /* If the element is a gobject, unreference it. */
+  if(a->type == LTTV_GOBJECT && a->value.dv_gobject != NULL)
+    g_object_unref(a->value.dv_gobject);
+  
   /* Remove the array element and its entry in the name index */
 
   g_hash_table_remove(self->names, GUINT_TO_POINTER(a->name));
@@ -234,7 +238,7 @@ lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
 }
 
 
-void lttv_attribute_recursive_free(LttvAttribute *self)
+/*void lttv_attribute_recursive_free(LttvAttribute *self)
 {
   int i, nb;
 
@@ -249,7 +253,7 @@ void lttv_attribute_recursive_free(LttvAttribute *self)
     }
   }
   g_object_unref(self);
-}
+}*/
 
 
 void lttv_attribute_recursive_add(LttvAttribute *dest, LttvAttribute *src)
@@ -272,7 +276,7 @@ void lttv_attribute_recursive_add(LttvAttribute *dest, LttvAttribute *src)
     else {
       g_assert(lttv_attribute_find(dest, a->name, a->type, &value));
       switch(a->type) {
-       case LTTV_INT:
+             case LTTV_INT:
           *value.v_int += a->value.dv_int;
           break;
         case LTTV_UINT:
index 76ed2f1e17585a93e46a6ff0ea835f052b4fe93d..517b4787a9d00eda435f514449fd8f1602149950 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef ATTRIBUTE_H
 #define ATTRIBUTE_H
 
-/* FIXME : unnamed attributed not implemented */
+/* FIXME : unnamed attributes not implemented */
 
 #include <glib-object.h>
 #include <lttv/iattribute.h>
@@ -110,7 +110,8 @@ gboolean lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
 /* Free recursively a tree of attributes. All contained gobject of type
    LttvAttribute are freed (unreferenced) recursively. */
 
-void lttv_attribute_recursive_free(LttvAttribute *self);
+// Now done by default.
+// void lttv_attribute_recursive_free(LttvAttribute *self);
 
 /* Add items from a tree of attributes to another tree. */
 
index 4293c828806bb29f9a37e7266775a95dea2c6e2e..ef357dd5b050e87fc95e59e809232c98b3ce26d9 100644 (file)
@@ -270,7 +270,8 @@ void lttv_iattribute_copy_value(LttvAttributeType t, LttvAttributeValue dest,
       break;
 
     case LTTV_GOBJECT:
-      *(dest.v_gobject) = *(src.v_gobject); 
+      *(dest.v_gobject) = *(src.v_gobject);
+      if(*(dest.v_gobject) != NULL) g_object_ref(*(dest.v_gobject));
       break;
 
     case LTTV_NONE:
index 0bf10ad72d474443e174ace412d063f32dd1903e..0783077f646473fd3d33f584575ad6b3a8348a46 100644 (file)
@@ -16,7 +16,7 @@
  * MA 02111-1307, USA.
  */
 
-/* FIXME : unnamed attributed not implemented */
+/* FIXME : unnamed attributes not implemented */
 
 #ifndef IATTRIBUTE_H
 #define IATTRIBUTE_H
    and access functions over a wide range of structures. The names are 
    represented by unique integer identifiers, GQuarks. */
 
+/* Please note that adding a value of type gobject that is non null does not
+ * increment the reference count of this object : the actual reference to
+ * the object is "given" to the attribute tree. When the gobject value
+ * is removed, the object is unreferenced. A value copy through
+ * lttv_iattribute_copy_value does increase the reference count of the 
+ * gobject. */
+
 typedef GQuark LttvAttributeName;
 
 typedef enum _LttvAttributeType {
@@ -127,7 +134,6 @@ LttvAttributeType lttv_iattribute_get_by_name(LttvIAttribute *self,
 LttvAttributeValue lttv_iattribute_add(LttvIAttribute *self, 
     LttvAttributeName name, LttvAttributeType t);
 
-
 /* Remove an attribute */
 
 void lttv_iattribute_remove(LttvIAttribute *self, unsigned i);
index aa235f2d27ee350580ec30ac8613198b9d900b72..d8cbe8c63c2c4a83f1e018981e231bc2ce66a649 100644 (file)
@@ -472,6 +472,7 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
 
   tracefiles_tree = lttv_attribute_find_subdir(container, 
       LTTV_STATE_TRACEFILES);
+  g_object_ref(G_OBJECT(tracefiles_tree));
   lttv_attribute_remove_by_name(container, LTTV_STATE_TRACEFILES);
 
   type = lttv_attribute_get_by_name(container, LTTV_STATE_PROCESSES, 
@@ -495,7 +496,7 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
     g_assert(type == LTTV_POINTER);
     if(*(value.v_pointer) != NULL) g_free(*(value.v_pointer));
   }
-  lttv_attribute_recursive_free(tracefiles_tree);
+  g_object_unref(G_OBJECT(tracefiles_tree));
 }
 
 
@@ -522,7 +523,6 @@ static void free_saved_state(LttvTraceState *self)
   }
 
   lttv_attribute_remove_by_name(self->parent.t_a, LTTV_STATE_SAVED_STATES);
-  lttv_attribute_recursive_free(saved_states);
 }
 
 
index d36438dc5a8327c50ee88e30714050dff949e93e..fa697d0c0dfe11c044684558ef5743fd22953ae6 100644 (file)
@@ -149,7 +149,6 @@ fini(LttvTracesetStats *self)
 
   if(*(v.v_uint) == 0) {
     lttv_attribute_remove_by_name(self->parent.parent.ts_a, LTTV_STATS);
-    lttv_attribute_recursive_free(self->stats);
   }
   self->stats = NULL;
 
@@ -165,12 +164,10 @@ fini(LttvTracesetStats *self)
 
     if(*(v.v_uint) == 0) { 
       lttv_attribute_remove_by_name(tcs->parent.parent.t_a,LTTV_STATS);
-      lttv_attribute_recursive_free(tcs->stats);
       tracefiles_stats = lttv_attribute_find_subdir(tcs->parent.parent.t_a, 
           LTTV_STATS_TRACEFILES);
       lttv_attribute_remove_by_name(tcs->parent.parent.t_a,
           LTTV_STATS_TRACEFILES);
-      lttv_attribute_recursive_free(tracefiles_stats);
     }
     tcs->stats = NULL;
 
This page took 0.026932 seconds and 4 git commands to generate.