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));
}
-void lttv_attribute_recursive_free(LttvAttribute *self)
+/*void lttv_attribute_recursive_free(LttvAttribute *self)
{
int i, nb;
}
}
g_object_unref(self);
-}
+}*/
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:
#ifndef ATTRIBUTE_H
#define ATTRIBUTE_H
-/* FIXME : unnamed attributed not implemented */
+/* FIXME : unnamed attributes not implemented */
#include <glib-object.h>
#include <lttv/iattribute.h>
/* 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. */
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:
* 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 {
LttvAttributeValue lttv_iattribute_add(LttvIAttribute *self,
LttvAttributeName name, LttvAttributeType t);
-
/* Remove an attribute */
void lttv_iattribute_remove(LttvIAttribute *self, unsigned i);
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,
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));
}
}
lttv_attribute_remove_by_name(self->parent.t_a, LTTV_STATE_SAVED_STATES);
- lttv_attribute_recursive_free(saved_states);
}
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;
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;