From 50f54e757ca63df54eba9ca7125d1f4244239f2c Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 28 Sep 2001 21:17:30 +0000 Subject: g_strdup (pas_backend_file_changes): ditto, make sure to free all data and 2001-09-28 JP Rosevear * backend/pas/pas-backend-file.c (pas_backend_file_changes_foreach_key): g_strdup (pas_backend_file_changes): ditto, make sure to free all data and do a hash write after each add/remove * conduit/address-conduit.c (local_record_to_pilot_record): use the local record category (local_record_from_ecard): ndle the fields and category we don't sync by making sure we don't overwrite them svn path=/trunk/; revision=13232 --- addressbook/backend/pas/pas-backend-file.c | 63 ++++++++++++++++++------------ 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'addressbook/backend/pas') diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index 990d53e704..b8ef4931fb 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -349,7 +349,7 @@ pas_backend_file_changes_foreach_key (const char *key, gpointer user_data) if (db_error == DB_NOTFOUND) { char *id = id_dbt.data; - ctx->del_ids = g_list_append (ctx->del_ids, strdup (id)); + ctx->del_ids = g_list_append (ctx->del_ids, g_strdup (id)); } } @@ -409,12 +409,14 @@ pas_backend_file_changes (PASBackendFile *bf, case E_DBHASH_STATUS_SAME: break; case E_DBHASH_STATUS_NOT_FOUND: - ctx->add_cards = g_list_append (ctx->add_cards, strdup(vcard_string)); - ctx->add_ids = g_list_append (ctx->add_ids, strdup(id)); + ctx->add_cards = g_list_append (ctx->add_cards, + g_strdup(vcard_string)); + ctx->add_ids = g_list_append (ctx->add_ids, g_strdup(id)); break; case E_DBHASH_STATUS_DIFFERENT: - ctx->mod_cards = g_list_append (ctx->mod_cards, strdup(vcard_string)); - ctx->mod_ids = g_list_append (ctx->mod_ids, strdup(id)); + ctx->mod_cards = g_list_append (ctx->mod_cards, + g_strdup(vcard_string)); + ctx->mod_ids = g_list_append (ctx->mod_ids, g_strdup(id)); break; } } @@ -426,25 +428,6 @@ pas_backend_file_changes (PASBackendFile *bf, e_dbhash_foreach_key (ehash, (EDbHashFunc)pas_backend_file_changes_foreach_key, view->change_context); - /* Update the hash */ - for (i = ctx->add_ids, v = ctx->add_cards; i != NULL; i = i->next, v = v->next){ - char *id = i->data; - char *vcard = v->data; - e_dbhash_add (ehash, id, vcard); - } - for (i = ctx->mod_ids, v = ctx->mod_cards; i != NULL; i = i->next, v = v->next){ - char *id = i->data; - char *vcard = v->data; - e_dbhash_add (ehash, id, vcard); - } - for (i = ctx->del_ids; i != NULL; i = i->next){ - char *id = i->data; - e_dbhash_remove (ehash, id); - } - - e_dbhash_write (ehash); - e_dbhash_destroy (ehash); - /* Send the changes */ if (db_error != DB_NOTFOUND) { g_warning ("pas_backend_file_changes: error building list\n"); @@ -462,6 +445,38 @@ pas_backend_file_changes (PASBackendFile *bf, pas_book_view_notify_complete (view->book_view); } + + /* Update the hash */ + for (i = ctx->add_ids, v = ctx->add_cards; i != NULL; i = i->next, v = v->next){ + char *id = i->data; + char *vcard = v->data; + + e_dbhash_add (ehash, id, vcard); + e_dbhash_write (ehash); + + g_free (i->data); + g_free (v->data); + } + for (i = ctx->mod_ids, v = ctx->mod_cards; i != NULL; i = i->next, v = v->next){ + char *id = i->data; + char *vcard = v->data; + + e_dbhash_add (ehash, id, vcard); + e_dbhash_write (ehash); + + g_free (i->data); + g_free (v->data); + } + for (i = ctx->del_ids; i != NULL; i = i->next){ + char *id = i->data; + + e_dbhash_remove (ehash, id); + e_dbhash_write (ehash); + + g_free (i->data); + } + + e_dbhash_destroy (ehash); } static char * -- cgit v1.2.3