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));
Attribute a;
LttvAttribute *new;
-
+
i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name));
if(i != 0) {
a = g_array_index(self->attributes, Attribute, i - 1);
}
-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:
for(i = 0 ; i < nb ; i++) {
a = &g_array_index(self->attributes, Attribute, i);
print_indent(fp, pos);
- fprintf(fp, "<ATTR NAME=\"%s\" ", a->name);
+ fprintf(fp, "<ATTR NAME=\"%s\" ", g_quark_to_string(a->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,
fscanf(fp,"</ATTRS>");
}
+static LttvAttribute *
+new_attribute (LttvAttribute *self)
+{
+ return g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
+}
+
static void
attribute_interface_init (gpointer g_iface, gpointer iface_data)
{
LttvIAttributeClass *klass = (LttvIAttributeClass *)g_iface;
+ klass->new_attribute = (LttvIAttribute* (*) (LttvIAttribute *self))
+ new_attribute;
+
klass->get_number = (unsigned int (*) (LttvIAttribute *self))
lttv_attribute_get_number;
klass->find_subdir = (LttvIAttribute* (*) (LttvIAttribute *self,
LttvAttributeName name)) lttv_attribute_find_subdir;
+
}
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;i<self->attributes->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));
}
attribute_class_init (LttvAttributeClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
+
gobject_class->finalize = (void (*)(GObject *self))attribute_finalize;
}