diff options
Diffstat (limited to 'addressbook/backend')
-rw-r--r-- | addressbook/backend/ebook/e-card-simple.c | 79 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card-simple.h | 1 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card-types.h | 15 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card.c | 212 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card.h | 15 |
5 files changed, 190 insertions, 132 deletions
diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c index 1dac48d86d..2ef73e17f6 100644 --- a/addressbook/backend/ebook/e-card-simple.c +++ b/addressbook/backend/ebook/e-card-simple.c @@ -345,13 +345,13 @@ e_card_simple_destroy (GtkObject *object) simple->temp_fields = NULL; for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) - e_card_phone_free (simple->phone[i]); + e_card_phone_unref (simple->phone[i]); for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) g_free(simple->email[i]); for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) - e_card_address_label_free(simple->address[i]); + e_card_address_label_unref(simple->address[i]); for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) - e_card_delivery_address_free(simple->delivery[i]); + e_card_delivery_address_unref(simple->delivery[i]); } @@ -446,7 +446,7 @@ fill_in_info(ECardSimple *simple) "email", &email_list, NULL); for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) { - e_card_phone_free(simple->phone[i]); + e_card_phone_unref(simple->phone[i]); simple->phone[i] = NULL; } for (iterator = e_list_get_iterator(phone_list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { @@ -454,7 +454,7 @@ fill_in_info(ECardSimple *simple) phone = e_iterator_get(iterator); for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) { if ((phone->flags == phone_correspondences[i]) && (simple->phone[i] == NULL)) { - simple->phone[i] = e_card_phone_copy(phone); + simple->phone[i] = e_card_phone_ref(phone); found = TRUE; break; } @@ -463,7 +463,7 @@ fill_in_info(ECardSimple *simple) continue; for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) { if (((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) && (simple->phone[i] == NULL)) { - simple->phone[i] = e_card_phone_copy(phone); + simple->phone[i] = e_card_phone_ref(phone); break; } } @@ -486,14 +486,14 @@ fill_in_info(ECardSimple *simple) gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { - e_card_address_label_free(simple->address[i]); + e_card_address_label_unref(simple->address[i]); simple->address[i] = NULL; } for (iterator = e_list_get_iterator(address_list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { address = e_iterator_get(iterator); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) { if (((address->flags & addr_correspondences[i]) == addr_correspondences[i]) && (simple->address[i] == NULL)) { - simple->address[i] = e_card_address_label_copy(address); + simple->address[i] = e_card_address_label_ref(address); break; } } @@ -501,14 +501,14 @@ fill_in_info(ECardSimple *simple) gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { - e_card_delivery_address_free(simple->delivery[i]); + e_card_delivery_address_unref(simple->delivery[i]); simple->delivery[i] = NULL; } for (iterator = e_list_get_iterator(delivery_list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { delivery = e_iterator_get(iterator); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) { if (((delivery->flags & addr_correspondences[i]) == addr_correspondences[i]) && (simple->delivery[i] == NULL)) { - simple->delivery[i] = e_card_delivery_address_copy(delivery); + simple->delivery[i] = e_card_delivery_address_ref(delivery); break; } } @@ -555,7 +555,7 @@ e_card_simple_sync_card(ECardSimple *simple) } else { e_iterator_delete(iterator); } - e_card_phone_free(simple->phone[i]); + e_card_phone_unref(simple->phone[i]); simple->phone[i] = NULL; found = TRUE; break; @@ -573,7 +573,7 @@ e_card_simple_sync_card(ECardSimple *simple) } else { e_iterator_delete(iterator); } - e_card_phone_free(simple->phone[i]); + e_card_phone_unref(simple->phone[i]); simple->phone[i] = NULL; break; } @@ -585,7 +585,7 @@ e_card_simple_sync_card(ECardSimple *simple) if (simple->phone[i]) { simple->phone[i]->flags = phone_correspondences[i]; e_list_append(phone_list, simple->phone[i]); - e_card_phone_free(simple->phone[i]); + e_card_phone_unref(simple->phone[i]); simple->phone[i] = NULL; } } @@ -627,7 +627,7 @@ e_card_simple_sync_card(ECardSimple *simple) } else { e_iterator_delete(iterator); } - e_card_address_label_free(simple->address[i]); + e_card_address_label_unref(simple->address[i]); simple->address[i] = NULL; break; } @@ -639,7 +639,7 @@ e_card_simple_sync_card(ECardSimple *simple) if (simple->address[i]) { simple->address[i]->flags = addr_correspondences[i]; e_list_append(address_list, simple->address[i]); - e_card_address_label_free(simple->address[i]); + e_card_address_label_unref(simple->address[i]); simple->address[i] = NULL; } } @@ -656,7 +656,7 @@ e_card_simple_sync_card(ECardSimple *simple) } else { e_iterator_delete(iterator); } - e_card_delivery_address_free(simple->delivery[i]); + e_card_delivery_address_unref(simple->delivery[i]); simple->delivery[i] = NULL; break; } @@ -668,7 +668,7 @@ e_card_simple_sync_card(ECardSimple *simple) if (simple->delivery[i]) { simple->delivery[i]->flags = addr_correspondences[i]; e_list_append(delivery_list, simple->delivery[i]); - e_card_delivery_address_free(simple->delivery[i]); + e_card_delivery_address_unref(simple->delivery[i]); simple->delivery[i] = NULL; } } @@ -707,9 +707,8 @@ void e_card_simple_set_phone (ECardSimple *simple, ECardSimplePhoneId id, const ECardPhone *phone) { - if (simple->phone[id]) - e_card_phone_free(simple->phone[id]); - simple->phone[id] = e_card_phone_copy(phone); + e_card_phone_unref(simple->phone[id]); + simple->phone[id] = e_card_phone_ref(phone); simple->changed = TRUE; } @@ -717,21 +716,17 @@ void e_card_simple_set_email (ECardSimple *simple, ECardSimpleEmailId id, const char *email) { - if (simple->email[id]) - g_free(simple->email[id]); + g_free(simple->email[id]); simple->email[id] = g_strdup(email); simple->changed = TRUE; } -void e_card_simple_set_address (ECardSimple *simple, - ECardSimpleAddressId id, - const ECardAddrLabel *address) +void +e_card_simple_set_address (ECardSimple *simple, ECardSimpleAddressId id, const ECardAddrLabel *address) { - if (simple->address[id]) - e_card_address_label_free(simple->address[id]); - simple->address[id] = e_card_address_label_copy(address); - if (simple->delivery[id]) - e_card_delivery_address_free(simple->delivery[id]); + e_card_address_label_unref(simple->address[id]); + simple->address[id] = e_card_address_label_ref(address); + e_card_delivery_address_unref(simple->delivery[id]); simple->delivery[id] = e_card_delivery_address_from_label(simple->address[id]); simple->changed = TRUE; } @@ -740,9 +735,8 @@ void e_card_simple_set_delivery_address (ECardSimple *simple ECardSimpleAddressId id, const ECardDeliveryAddress *delivery) { - if (simple->delivery[id]) - e_card_delivery_address_free(simple->delivery[id]); - simple->delivery[id] = e_card_delivery_address_copy(delivery); + e_card_delivery_address_unref(simple->delivery[id]); + simple->delivery[id] = e_card_delivery_address_ref(delivery); simple->changed = TRUE; } @@ -954,8 +948,7 @@ file_as_get_style (ECardSimple *simple) g_free(filestring); g_free(full_name); g_free(company); - if (name) - e_card_name_free(name); + e_card_name_unref(name); return style; } @@ -981,7 +974,7 @@ file_as_set_style(ECardSimple *simple, int style) } g_free(full_name); g_free(company); - e_card_name_free(name); + e_card_name_unref(name); } } @@ -1014,21 +1007,19 @@ void e_card_simple_set (ECardSimple *simple, break; /* FIXME!!!! */ case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS: address = e_card_address_label_new(); - address->data = (char *) data; + address->data = g_strdup (data); e_card_simple_set_address(simple, field_data[field].list_type_index, address); - address->data = NULL; - e_card_address_label_free(address); + e_card_address_label_unref(address); break; case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE: phone = e_card_phone_new(); - phone->number = (char *) data; + phone->number = g_strdup (data); e_card_simple_set_phone(simple, field_data[field].list_type_index, phone); - phone->number = NULL; - e_card_phone_free(phone); + e_card_phone_unref(phone); break; case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL: e_card_simple_set_email(simple, @@ -1141,7 +1132,7 @@ void e_card_simple_set_arbitrary (ECardSimple *sim new_arb->type = g_strdup(type); new_arb->value = g_strdup(value); e_iterator_set(iterator, new_arb); - e_card_arbitrary_free(new_arb); + e_card_arbitrary_unref(new_arb); return; } } @@ -1150,7 +1141,7 @@ void e_card_simple_set_arbitrary (ECardSimple *sim new_arb->type = g_strdup(type); new_arb->value = g_strdup(value); e_list_append(list, new_arb); - e_card_arbitrary_free(new_arb); + e_card_arbitrary_unref(new_arb); } } diff --git a/addressbook/backend/ebook/e-card-simple.h b/addressbook/backend/ebook/e-card-simple.h index 0d353f00da..1639e4d71b 100644 --- a/addressbook/backend/ebook/e-card-simple.h +++ b/addressbook/backend/ebook/e-card-simple.h @@ -116,6 +116,7 @@ enum _ECardSimpleField { E_CARD_SIMPLE_FIELD_NOTE, E_CARD_SIMPLE_FIELD_CALURI, E_CARD_SIMPLE_FIELD_FBURL, + /* If you add after FBURL, make sure to move LAST_SIMPLE_STRING */ E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING = E_CARD_SIMPLE_FIELD_FBURL, E_CARD_SIMPLE_FIELD_ANNIVERSARY, E_CARD_SIMPLE_FIELD_BIRTH_DATE, diff --git a/addressbook/backend/ebook/e-card-types.h b/addressbook/backend/ebook/e-card-types.h index 13854c30e7..588a1f5e68 100644 --- a/addressbook/backend/ebook/e-card-types.h +++ b/addressbook/backend/ebook/e-card-types.h @@ -14,11 +14,12 @@ /* IDENTIFICATION PROPERTIES */ typedef struct { - char *prefix; /* Mr. */ - char *given; /* John */ - char *additional; /* Quinlan */ - char *family; /* Public */ - char *suffix; /* Esq. */ + gint ref_count; + char *prefix; /* Mr. */ + char *given; /* John */ + char *additional; /* Quinlan */ + char *family; /* Public */ + char *suffix; /* Esq. */ } ECardName; typedef struct { @@ -51,6 +52,7 @@ typedef enum { } ECardPhoneFlags; typedef struct { + gint ref_count; ECardPhoneFlags flags; char *number; } ECardPhone; @@ -67,6 +69,7 @@ typedef enum { } ECardAddressFlags; typedef struct { + gint ref_count; ECardAddressFlags flags; char *po; @@ -79,6 +82,7 @@ typedef struct { } ECardDeliveryAddress; typedef struct { + gint ref_count; ECardAddressFlags flags; char *data; } ECardAddrLabel; @@ -86,6 +90,7 @@ typedef struct { /* ARBITRARY PROPERTIES */ typedef struct { + gint ref_count; char *key; char *type; char *value; diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c index 1b3ef694b6..216971c650 100644 --- a/addressbook/backend/ebook/e-card.c +++ b/addressbook/backend/ebook/e-card.c @@ -781,10 +781,9 @@ parse_file_as(ECard *card, VObject *vobj, char *default_charset) static void parse_name(ECard *card, VObject *vobj, char *default_charset) { - if ( card->name ) { - e_card_name_free(card->name); - } - card->name = g_new(ECardName, 1); + e_card_name_unref(card->name); + + card->name = e_card_name_new(); card->name->family = e_v_object_get_child_value (vobj, VCFamilyNameProp, default_charset); card->name->given = e_v_object_get_child_value (vobj, VCGivenNameProp, default_charset); @@ -832,7 +831,7 @@ parse_bday(ECard *card, VObject *vobj, char *default_charset) static void parse_phone(ECard *card, VObject *vobj, char *default_charset) { - ECardPhone *next_phone = g_new(ECardPhone, 1); + ECardPhone *next_phone = e_card_phone_new (); EList *list; assign_string(vobj, default_charset, &(next_phone->number)); @@ -842,13 +841,13 @@ parse_phone(ECard *card, VObject *vobj, char *default_charset) "phone", &list, NULL); e_list_append(list, next_phone); - e_card_phone_free (next_phone); + e_card_phone_unref (next_phone); } static void parse_address(ECard *card, VObject *vobj, char *default_charset) { - ECardDeliveryAddress *next_addr = g_new(ECardDeliveryAddress, 1); + ECardDeliveryAddress *next_addr = e_card_delivery_address_new (); EList *list; next_addr->flags = get_address_flags (vobj); @@ -864,13 +863,13 @@ parse_address(ECard *card, VObject *vobj, char *default_charset) "address", &list, NULL); e_list_append(list, next_addr); - e_card_delivery_address_free (next_addr); + e_card_delivery_address_unref (next_addr); } static void parse_address_label(ECard *card, VObject *vobj, char *default_charset) { - ECardAddrLabel *next_addr = g_new(ECardAddrLabel, 1); + ECardAddrLabel *next_addr = e_card_address_label_new (); EList *list; next_addr->flags = get_address_flags (vobj); @@ -880,7 +879,7 @@ parse_address_label(ECard *card, VObject *vobj, char *default_charset) "address_label", &list, NULL); e_list_append(list, next_addr); - e_card_address_label_free (next_addr); + e_card_address_label_unref (next_addr); } static void @@ -1169,7 +1168,7 @@ parse_arbitrary(ECard *card, VObject *vobj, char *default_charset) "arbitrary", &list, NULL); e_list_append(list, arbitrary); - e_card_arbitrary_free(arbitrary); + e_card_arbitrary_unref(arbitrary); } static void @@ -1337,6 +1336,7 @@ e_card_phone_new (void) { ECardPhone *newphone = g_new(ECardPhone, 1); + newphone->ref_count = 1; newphone->number = NULL; newphone->flags = 0; @@ -1344,20 +1344,31 @@ e_card_phone_new (void) } void -e_card_phone_free (ECardPhone *phone) +e_card_phone_unref (ECardPhone *phone) { - if ( phone ) { - g_free(phone->number); - - g_free(phone); + if (phone) { + phone->ref_count --; + if (phone->ref_count == 0) { + g_free(phone->number); + g_free(phone); + } } } ECardPhone * +e_card_phone_ref (const ECardPhone *phone) +{ + ECardPhone *phone_mutable = (ECardPhone *) phone; + if (phone_mutable) + phone_mutable->ref_count ++; + return phone_mutable; +} + +ECardPhone * e_card_phone_copy (const ECardPhone *phone) { if ( phone ) { - ECardPhone *phone_copy = g_new(ECardPhone, 1); + ECardPhone *phone_copy = e_card_phone_new(); phone_copy->number = g_strdup(phone->number); phone_copy->flags = phone->flags; return phone_copy; @@ -1370,6 +1381,7 @@ e_card_delivery_address_new (void) { ECardDeliveryAddress *newaddr = g_new(ECardDeliveryAddress, 1); + newaddr->ref_count = 1; newaddr->po = NULL; newaddr->ext = NULL; newaddr->street = NULL; @@ -1383,26 +1395,37 @@ e_card_delivery_address_new (void) } void -e_card_delivery_address_free (ECardDeliveryAddress *addr) +e_card_delivery_address_unref (ECardDeliveryAddress *addr) { if ( addr ) { - g_free(addr->po); - g_free(addr->ext); - g_free(addr->street); - g_free(addr->city); - g_free(addr->region); - g_free(addr->code); - g_free(addr->country); - - g_free(addr); + addr->ref_count --; + if (addr->ref_count == 0) { + g_free(addr->po); + g_free(addr->ext); + g_free(addr->street); + g_free(addr->city); + g_free(addr->region); + g_free(addr->code); + g_free(addr->country); + g_free(addr); + } } } ECardDeliveryAddress * +e_card_delivery_address_ref (const ECardDeliveryAddress *addr) +{ + ECardDeliveryAddress *addr_mutable = (ECardDeliveryAddress *) addr; + if (addr_mutable) + addr_mutable->ref_count ++; + return addr_mutable; +} + +ECardDeliveryAddress * e_card_delivery_address_copy (const ECardDeliveryAddress *addr) { if ( addr ) { - ECardDeliveryAddress *addr_copy = g_new(ECardDeliveryAddress, 1); + ECardDeliveryAddress *addr_copy = e_card_delivery_address_new (); addr_copy->po = g_strdup(addr->po ); addr_copy->ext = g_strdup(addr->ext ); addr_copy->street = g_strdup(addr->street ); @@ -1431,7 +1454,7 @@ e_card_delivery_address_is_empty (const ECardDeliveryAddress *addr) ECardDeliveryAddress * e_card_delivery_address_from_label(const ECardAddrLabel *label) { - ECardDeliveryAddress *addr = g_new(ECardDeliveryAddress, 1); + ECardDeliveryAddress *addr = e_card_delivery_address_new (); EAddressWestern *western = e_address_western_parse (label->data); addr->po = g_strdup (western->po_box ); @@ -1507,6 +1530,7 @@ e_card_address_label_new (void) { ECardAddrLabel *newaddr = g_new(ECardAddrLabel, 1); + newaddr->ref_count = 1; newaddr->data = NULL; newaddr->flags = 0; @@ -1514,22 +1538,33 @@ e_card_address_label_new (void) } void -e_card_address_label_free (ECardAddrLabel *addr) +e_card_address_label_unref (ECardAddrLabel *addr) { - if ( addr ) { - g_free(addr->data); - - g_free(addr); + if (addr) { + addr->ref_count --; + if (addr->ref_count == 0) { + g_free(addr->data); + g_free(addr); + } } } ECardAddrLabel * +e_card_address_label_ref (const ECardAddrLabel *addr) +{ + ECardAddrLabel *addr_mutable = (ECardAddrLabel *) addr; + if (addr_mutable) + addr_mutable->ref_count ++; + return addr_mutable; +} + +ECardAddrLabel * e_card_address_label_copy (const ECardAddrLabel *addr) { if ( addr ) { - ECardAddrLabel *addr_copy = g_new(ECardAddrLabel, 1); - addr_copy->data = g_strdup(addr->data); - addr_copy->flags = addr->flags; + ECardAddrLabel *addr_copy = e_card_address_label_new (); + addr_copy->data = g_strdup(addr->data); + addr_copy->flags = addr->flags; return addr_copy; } else return NULL; @@ -1537,8 +1572,9 @@ e_card_address_label_copy (const ECardAddrLabel *addr) ECardName *e_card_name_new(void) { - ECardName *newname = g_new(ECardName, 1); + ECardName *newname = g_new(ECardName, 1); + newname->ref_count = 1; newname->prefix = NULL; newname->given = NULL; newname->additional = NULL; @@ -1549,29 +1585,36 @@ ECardName *e_card_name_new(void) } void -e_card_name_free(ECardName *name) +e_card_name_unref(ECardName *name) { if (name) { - if ( name->prefix ) - g_free(name->prefix); - if ( name->given ) - g_free(name->given); - if ( name->additional ) - g_free(name->additional); - if ( name->family ) - g_free(name->family); - if ( name->suffix ) - g_free(name->suffix); - g_free ( name ); + name->ref_count --; + if (name->ref_count == 0) { + g_free (name->prefix); + g_free (name->given); + g_free (name->additional); + g_free (name->family); + g_free (name->suffix); + g_free (name); + } } } ECardName * +e_card_name_ref(const ECardName *name) +{ + ECardName *name_mutable = (ECardName *) name; + if (name_mutable) + name_mutable->ref_count ++; + return name_mutable; +} + +ECardName * e_card_name_copy(const ECardName *name) { if (name) { - ECardName *newname = g_new(ECardName, 1); - + ECardName *newname = e_card_name_new (); + newname->prefix = g_strdup(name->prefix); newname->given = g_strdup(name->given); newname->additional = g_strdup(name->additional); @@ -1583,6 +1626,7 @@ e_card_name_copy(const ECardName *name) return NULL; } + char * e_card_name_to_string(const ECardName *name) { @@ -1607,7 +1651,7 @@ e_card_name_to_string(const ECardName *name) ECardName * e_card_name_from_string(const char *full_name) { - ECardName *name = g_new(ECardName, 1); + ECardName *name = e_card_name_new (); ENameWestern *western = e_name_western_parse (full_name); name->prefix = g_strdup (western->prefix); @@ -1625,17 +1669,32 @@ ECardArbitrary * e_card_arbitrary_new(void) { ECardArbitrary *arbitrary = g_new(ECardArbitrary, 1); + arbitrary->ref_count = 1; arbitrary->key = NULL; arbitrary->type = NULL; arbitrary->value = NULL; return arbitrary; } +void +e_card_arbitrary_unref(ECardArbitrary *arbitrary) +{ + if (arbitrary) { + arbitrary->ref_count --; + if (arbitrary->ref_count == 0) { + g_free(arbitrary->key); + g_free(arbitrary->type); + g_free(arbitrary->value); + g_free(arbitrary); + } + } +} + ECardArbitrary * e_card_arbitrary_copy(const ECardArbitrary *arbitrary) { if (arbitrary) { - ECardArbitrary *arb_copy = g_new(ECardArbitrary, 1); + ECardArbitrary *arb_copy = e_card_arbitrary_new (); arb_copy->key = g_strdup(arbitrary->key); arb_copy->type = g_strdup(arbitrary->type); arb_copy->value = g_strdup(arbitrary->value); @@ -1644,15 +1703,13 @@ e_card_arbitrary_copy(const ECardArbitrary *arbitrary) return NULL; } -void -e_card_arbitrary_free(ECardArbitrary *arbitrary) +ECardArbitrary * +e_card_arbitrary_ref(const ECardArbitrary *arbitrary) { - if (arbitrary) { - g_free(arbitrary->key); - g_free(arbitrary->type); - g_free(arbitrary->value); - } - g_free(arbitrary); + ECardArbitrary *arbitrary_mutable = (ECardArbitrary *) arbitrary; + if (arbitrary_mutable) + arbitrary_mutable->ref_count ++; + return arbitrary_mutable; } /* EMail matching */ @@ -1744,8 +1801,7 @@ e_card_destroy (GtkObject *object) gtk_object_unref (GTK_OBJECT (card->book)); g_free(card->file_as); g_free(card->fname); - if ( card->name ) - e_card_name_free(card->name); + e_card_name_unref(card->name); g_free(card->bday); g_free(card->url); @@ -1792,19 +1848,19 @@ e_card_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) if (card->file_as == NULL) card->file_as = g_strdup(""); break; + case ARG_FULL_NAME: g_free(card->fname); card->fname = g_strdup(GTK_VALUE_STRING(*arg)); - if (card->name) - e_card_name_free (card->name); if (card->fname == NULL) card->fname = g_strdup(""); + + e_card_name_unref (card->name); card->name = e_card_name_from_string (card->fname); break; case ARG_NAME: - if ( card->name ) - e_card_name_free(card->name); - card->name = e_card_name_copy(GTK_VALUE_POINTER(*arg)); + e_card_name_unref (card->name); + card->name = e_card_name_ref(GTK_VALUE_POINTER(*arg)); if (card->name == NULL) card->name = e_card_name_new(); if (card->fname == NULL) { @@ -1974,22 +2030,22 @@ e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_ADDRESS: if (!card->address) - card->address = e_list_new((EListCopyFunc) e_card_delivery_address_copy, - (EListFreeFunc) e_card_delivery_address_free, + card->address = e_list_new((EListCopyFunc) e_card_delivery_address_ref, + (EListFreeFunc) e_card_delivery_address_unref, NULL); GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->address); break; case ARG_ADDRESS_LABEL: if (!card->address_label) - card->address_label = e_list_new((EListCopyFunc) e_card_address_label_copy, - (EListFreeFunc) e_card_address_label_free, + card->address_label = e_list_new((EListCopyFunc) e_card_address_label_ref, + (EListFreeFunc) e_card_address_label_unref, NULL); GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->address_label); break; case ARG_PHONE: if (!card->phone) - card->phone = e_list_new((EListCopyFunc) e_card_phone_copy, - (EListFreeFunc) e_card_phone_free, + card->phone = e_list_new((EListCopyFunc) e_card_phone_ref, + (EListFreeFunc) e_card_phone_unref, NULL); GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->phone); break; @@ -2086,8 +2142,8 @@ e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_ARBITRARY: if (!card->arbitrary) - card->arbitrary = e_list_new((EListCopyFunc) e_card_arbitrary_copy, - (EListFreeFunc) e_card_arbitrary_free, + card->arbitrary = e_list_new((EListCopyFunc) e_card_arbitrary_ref, + (EListFreeFunc) e_card_arbitrary_unref, NULL); GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->arbitrary); @@ -2731,7 +2787,7 @@ e_card_get_name (VObject *o) VObject *vo; char *the_str; - name = g_new0 (ECardName, 1); + name = e_card_name_new (); name->family = e_card_prop_get_substr (o, VCFamilyNameProp); name->given = e_card_prop_get_substr (o, VCGivenNameProp); diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h index 3f2334023b..242c9738b7 100644 --- a/addressbook/backend/ebook/e-card.h +++ b/addressbook/backend/ebook/e-card.h @@ -142,12 +142,14 @@ gboolean e_card_evolution_list_show_addresses (ECard /* ECardPhone manipulation */ ECardPhone *e_card_phone_new (void); ECardPhone *e_card_phone_copy (const ECardPhone *phone); -void e_card_phone_free (ECardPhone *phone); +ECardPhone *e_card_phone_ref (const ECardPhone *phone); +void e_card_phone_unref (ECardPhone *phone); /* ECardDeliveryAddress manipulation */ ECardDeliveryAddress *e_card_delivery_address_new (void); ECardDeliveryAddress *e_card_delivery_address_copy (const ECardDeliveryAddress *addr); -void e_card_delivery_address_free (ECardDeliveryAddress *addr); +ECardDeliveryAddress *e_card_delivery_address_ref (const ECardDeliveryAddress *addr); +void e_card_delivery_address_unref (ECardDeliveryAddress *addr); gboolean e_card_delivery_address_is_empty (const ECardDeliveryAddress *addr); char *e_card_delivery_address_to_string (const ECardDeliveryAddress *addr); ECardDeliveryAddress *e_card_delivery_address_from_label (const ECardAddrLabel *label); @@ -156,19 +158,22 @@ ECardAddrLabel *e_card_delivery_address_to_label (const /* ECardAddrLabel manipulation */ ECardAddrLabel *e_card_address_label_new (void); ECardAddrLabel *e_card_address_label_copy (const ECardAddrLabel *addr); -void e_card_address_label_free (ECardAddrLabel *addr); +ECardAddrLabel *e_card_address_label_ref (const ECardAddrLabel *addr); +void e_card_address_label_unref (ECardAddrLabel *addr); /* ECardName manipulation */ ECardName *e_card_name_new (void); ECardName *e_card_name_copy (const ECardName *name); -void e_card_name_free (ECardName *name); +ECardName *e_card_name_ref (const ECardName *name); +void e_card_name_unref (ECardName *name); char *e_card_name_to_string (const ECardName *name); ECardName *e_card_name_from_string (const char *full_name); /* ECardArbitrary manipulation */ ECardArbitrary *e_card_arbitrary_new (void); ECardArbitrary *e_card_arbitrary_copy (const ECardArbitrary *arbitrary); -void e_card_arbitrary_free (ECardArbitrary *arbitrary); +ECardArbitrary *e_card_arbitrary_ref (const ECardArbitrary *arbitrary); +void e_card_arbitrary_unref (ECardArbitrary *arbitrary); /* ECard email manipulation */ gboolean e_card_email_match_string (const ECard *card, |