X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fattribute.c;h=0eef75b80474263f1baa9e9fa0d6c5be2eeba13d;hb=4d39be09fda397de58798c73a8273517767e3e93;hp=ff69db2537bb3998ae100ec6772a88fcf723e45c;hpb=3e67c985ec32ef250e8b11dd29c13aad68fb4902;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/attribute.c b/ltt/branches/poly/lttv/lttv/attribute.c index ff69db25..0eef75b8 100644 --- a/ltt/branches/poly/lttv/lttv/attribute.c +++ b/ltt/branches/poly/lttv/lttv/attribute.c @@ -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: @@ -329,7 +333,7 @@ lttv_attribute_write_xml(LttvAttribute *self, FILE *fp, int pos, int indent) for(i = 0 ; i < nb ; i++) { a = &g_array_index(self->attributes, Attribute, i); print_indent(fp, pos); - fprintf(fp, "name); + fprintf(fp, "name)); if(a->type == LTTV_GOBJECT && LTTV_IS_ATTRIBUTE(a->value.dv_gobject)) { fprintf(fp, "TYPE=ATTRS>"); lttv_attribute_write_xml((LttvAttribute *)(a->value.dv_gobject), fp, @@ -506,6 +510,7 @@ attribute_interface_init (gpointer g_iface, gpointer iface_data) klass->find_subdir = (LttvIAttribute* (*) (LttvIAttribute *self, LttvAttributeName name)) lttv_attribute_find_subdir; + } @@ -521,11 +526,15 @@ attribute_instance_init (GTypeInstance *instance, gpointer g_class) static void attribute_finalize (LttvAttribute *self) { - g_hash_table_destroy(self->names); + guint i; g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "attribute_finalize()"); + + for(i=0;iattributes->len;i++) { + lttv_attribute_remove(self, i); + } + + g_hash_table_destroy(self->names); g_array_free(self->attributes, TRUE); - G_OBJECT_CLASS(g_type_class_peek_parent( - g_type_class_peek(LTTV_ATTRIBUTE_TYPE)))->finalize(G_OBJECT(self)); }