Blame SOURCES/evolution-data-server-3.28.5-vcard-attr-param-struct-reff.patch

f0a9c3
diff --git a/src/addressbook/libebook-contacts/e-vcard.c b/src/addressbook/libebook-contacts/e-vcard.c
f0a9c3
index e44b7fdcf..680cf85af 100644
f0a9c3
--- a/src/addressbook/libebook-contacts/e-vcard.c
f0a9c3
+++ b/src/addressbook/libebook-contacts/e-vcard.c
f0a9c3
@@ -120,6 +120,14 @@
f0a9c3
 
f0a9c3
 G_DEFINE_TYPE (EVCard, e_vcard, G_TYPE_OBJECT)
f0a9c3
 
f0a9c3
+static EVCardAttribute *e_vcard_attribute_ref (EVCardAttribute *attr);
f0a9c3
+static void e_vcard_attribute_unref (EVCardAttribute *attr);
f0a9c3
+static EVCardAttributeParam *e_vcard_attribute_param_ref (EVCardAttributeParam *param);
f0a9c3
+static void e_vcard_attribute_param_unref (EVCardAttributeParam *param);
f0a9c3
+
f0a9c3
+G_DEFINE_BOXED_TYPE (EVCardAttribute, e_vcard_attribute, e_vcard_attribute_ref, e_vcard_attribute_unref)
f0a9c3
+G_DEFINE_BOXED_TYPE (EVCardAttributeParam, e_vcard_attribute_param, e_vcard_attribute_param_ref, e_vcard_attribute_param_unref)
f0a9c3
+
f0a9c3
 /* Encoding used in v-card
f0a9c3
  * Note: v-card spec defines additional 7BIT 8BIT and X- encoding
f0a9c3
  */
f0a9c3
@@ -135,6 +143,7 @@ struct _EVCardPrivate {
f0a9c3
 };
f0a9c3
 
f0a9c3
 struct _EVCardAttribute {
f0a9c3
+	gint ref_count;
f0a9c3
 	gchar  *group;
f0a9c3
 	gchar  *name;
f0a9c3
 	GList *params; /* EVCardParam */
f0a9c3
@@ -145,6 +154,7 @@ struct _EVCardAttribute {
f0a9c3
 };
f0a9c3
 
f0a9c3
 struct _EVCardAttributeParam {
f0a9c3
+	gint ref_count;
f0a9c3
 	gchar     *name;
f0a9c3
 	GList    *values;  /* GList of gchar *'s */
f0a9c3
 };
f0a9c3
@@ -1555,6 +1565,7 @@ e_vcard_attribute_new (const gchar *attr_group,
f0a9c3
 	if (attr_group != NULL && *attr_group == '\0')
f0a9c3
 		attr_group = NULL;
f0a9c3
 
f0a9c3
+	attr->ref_count = 1;
f0a9c3
 	attr->group = g_strdup (attr_group);
f0a9c3
 	attr->name = g_strdup (attr_name);
f0a9c3
 
f0a9c3
@@ -1572,14 +1583,34 @@ e_vcard_attribute_free (EVCardAttribute *attr)
f0a9c3
 {
f0a9c3
 	g_return_if_fail (attr != NULL);
f0a9c3
 
f0a9c3
-	g_free (attr->group);
f0a9c3
-	g_free (attr->name);
f0a9c3
+	e_vcard_attribute_unref (attr);
f0a9c3
+}
f0a9c3
 
f0a9c3
-	e_vcard_attribute_remove_values (attr);
f0a9c3
+static EVCardAttribute *
f0a9c3
+e_vcard_attribute_ref (EVCardAttribute *attr)
f0a9c3
+{
f0a9c3
+	g_return_val_if_fail (attr != NULL, NULL);
f0a9c3
 
f0a9c3
-	e_vcard_attribute_remove_params (attr);
f0a9c3
+	g_atomic_int_inc (&attr->ref_count);
f0a9c3
 
f0a9c3
-	g_slice_free (EVCardAttribute, attr);
f0a9c3
+	return attr;
f0a9c3
+}
f0a9c3
+
f0a9c3
+static void
f0a9c3
+e_vcard_attribute_unref (EVCardAttribute *attr)
f0a9c3
+{
f0a9c3
+	g_return_if_fail (attr != NULL);
f0a9c3
+
f0a9c3
+	if (g_atomic_int_dec_and_test (&attr->ref_count)) {
f0a9c3
+		g_free (attr->group);
f0a9c3
+		g_free (attr->name);
f0a9c3
+
f0a9c3
+		e_vcard_attribute_remove_values (attr);
f0a9c3
+
f0a9c3
+		e_vcard_attribute_remove_params (attr);
f0a9c3
+
f0a9c3
+		g_slice_free (EVCardAttribute, attr);
f0a9c3
+	}
f0a9c3
 }
f0a9c3
 
f0a9c3
 /**
f0a9c3
@@ -1609,25 +1640,6 @@ e_vcard_attribute_copy (EVCardAttribute *attr)
f0a9c3
 	return a;
f0a9c3
 }
f0a9c3
 
f0a9c3
-GType
f0a9c3
-e_vcard_attribute_get_type (void)
f0a9c3
-{
f0a9c3
-	static volatile gsize type_id__volatile = 0;
f0a9c3
-
f0a9c3
-	if (g_once_init_enter (&type_id__volatile)) {
f0a9c3
-		GType type_id;
f0a9c3
-
f0a9c3
-		type_id = g_boxed_type_register_static (
f0a9c3
-			"EVCardAttribute",
f0a9c3
-			(GBoxedCopyFunc) e_vcard_attribute_copy,
f0a9c3
-			(GBoxedFreeFunc) e_vcard_attribute_free);
f0a9c3
-
f0a9c3
-		g_once_init_leave (&type_id__volatile, type_id);
f0a9c3
-	}
f0a9c3
-
f0a9c3
-	return type_id__volatile;
f0a9c3
-}
f0a9c3
-
f0a9c3
 /**
f0a9c3
  * e_vcard_remove_attributes:
f0a9c3
  * @evc: vcard object
f0a9c3
@@ -2068,25 +2080,6 @@ e_vcard_attribute_remove_params (EVCardAttribute *attr)
f0a9c3
 	attr->encoding = EVC_ENCODING_RAW;
f0a9c3
 }
f0a9c3
 
f0a9c3
-GType
f0a9c3
-e_vcard_attribute_param_get_type (void)
f0a9c3
-{
f0a9c3
-	static volatile gsize type_id__volatile = 0;
f0a9c3
-
f0a9c3
-	if (g_once_init_enter (&type_id__volatile)) {
f0a9c3
-		GType type_id;
f0a9c3
-
f0a9c3
-		type_id = g_boxed_type_register_static (
f0a9c3
-			"EVCardAttributeParam",
f0a9c3
-			(GBoxedCopyFunc) e_vcard_attribute_param_copy,
f0a9c3
-			(GBoxedFreeFunc) e_vcard_attribute_param_free);
f0a9c3
-
f0a9c3
-		g_once_init_leave (&type_id__volatile, type_id);
f0a9c3
-	}
f0a9c3
-
f0a9c3
-	return type_id__volatile;
f0a9c3
-}
f0a9c3
-
f0a9c3
 /**
f0a9c3
  * e_vcard_attribute_param_new:
f0a9c3
  * @name: the name of the new parameter
f0a9c3
@@ -2099,6 +2092,8 @@ EVCardAttributeParam *
f0a9c3
 e_vcard_attribute_param_new (const gchar *name)
f0a9c3
 {
f0a9c3
 	EVCardAttributeParam *param = g_slice_new (EVCardAttributeParam);
f0a9c3
+
f0a9c3
+	param->ref_count = 1;
f0a9c3
 	param->values = NULL;
f0a9c3
 	param->name = g_strdup (name);
f0a9c3
 
f0a9c3
@@ -2116,11 +2111,31 @@ e_vcard_attribute_param_free (EVCardAttributeParam *param)
f0a9c3
 {
f0a9c3
 	g_return_if_fail (param != NULL);
f0a9c3
 
f0a9c3
-	g_free (param->name);
f0a9c3
+	e_vcard_attribute_param_unref (param);
f0a9c3
+}
f0a9c3
+
f0a9c3
+static EVCardAttributeParam *
f0a9c3
+e_vcard_attribute_param_ref (EVCardAttributeParam *param)
f0a9c3
+{
f0a9c3
+	g_return_val_if_fail (param != NULL, NULL);
f0a9c3
+
f0a9c3
+	g_atomic_int_inc (&param->ref_count);
f0a9c3
+
f0a9c3
+	return param;
f0a9c3
+}
f0a9c3
+
f0a9c3
+static void
f0a9c3
+e_vcard_attribute_param_unref (EVCardAttributeParam *param)
f0a9c3
+{
f0a9c3
+	g_return_if_fail (param != NULL);
f0a9c3
+
f0a9c3
+	if (g_atomic_int_dec_and_test (&param->ref_count)) {
f0a9c3
+		g_free (param->name);
f0a9c3
 
f0a9c3
-	e_vcard_attribute_param_remove_values (param);
f0a9c3
+		e_vcard_attribute_param_remove_values (param);
f0a9c3
 
f0a9c3
-	g_slice_free (EVCardAttributeParam, param);
f0a9c3
+		g_slice_free (EVCardAttributeParam, param);
f0a9c3
+	}
f0a9c3
 }
f0a9c3
 
f0a9c3
 /**