diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2007-10-10 12:54:36 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2007-10-10 12:54:36 +0800 |
commit | b32649a94cd485f742d2ad5f1b76d7385393e137 (patch) | |
tree | 002248795c141c992667d73fbf34c40f394fbbf0 /e-util/e-pilot-map.c | |
parent | 6a2861c3aa49e9439d3e665b0855222716add3a3 (diff) | |
download | gsoc2013-evolution-b32649a94cd485f742d2ad5f1b76d7385393e137.tar.gz gsoc2013-evolution-b32649a94cd485f742d2ad5f1b76d7385393e137.tar.zst gsoc2013-evolution-b32649a94cd485f742d2ad5f1b76d7385393e137.zip |
** Fixes bug #437579
2007-10-09 Matthew Barnes <mbarnes@redhat.com>
** Fixes bug #437579
* addressbook/conduit/address-conduit.c:
* addressbook/gui/component/addressbook-config.c:
* addressbook/gui/contact-editor/e-contact-editor.c:
* addressbook/gui/widgets/eab-gui-util.c:
* calendar/conduits/calendar/calendar-conduit.c:
* calendar/conduits/memo/memo-conduit.c:
* calendar/conduits/todo/todo-conduit.c:
* calendar/gui/dialogs/alarm-dialog.c:
* calendar/gui/dialogs/event-page.c:
* calendar/gui/dialogs/memo-page.c:
* calendar/gui/dialogs/task-page.c:
* calendar/gui/e-day-view-layout.c:
* calendar/gui/e-day-view-layout.h:
* calendar/gui/print.c:
* e-util/e-pilot-map.c:
* e-util/e-plugin.c:
* e-util/e-profile-event.c:
* e-util/e-signature.c:
* filter/filter-file.c:
* mail/e-searching-tokenizer.c:
* mail/em-folder-browser.c:
* mail/em-format-html.c:
* mail/em-format-view.c:
* mail/em-format.c:
* mail/em-mailer-prefs.c:
* mail/em-mailer-prefs.h:
* mail/mail-session.c:
* mail/mail-session.h:
* mail/mail-vfolder.c:
* mail/message-list.c:
* plugins/bbdb/bbdb.c:
* plugins/bbdb/gaimbuddies.c:
* plugins/calendar-http/calendar-http.c:
* plugins/exchange-operations/exchange-user-dialog.c:
* plugins/face/face.c:
* shell/e-shell-window.c:
* shell/e-shell.c:
* smime/lib/e-cert-db.c:
* tools/killev.c:
* widgets/misc/e-cursors.c:
* widgets/misc/e-spinner.c:
* widgets/misc/e-unicode.c:
* widgets/table/e-table-field-chooser-item.c:
* widgets/table/e-table-header-item.c:
* widgets/table/e-table-header-item.h:
* widgets/table/e-table-header-utils.c:
* widgets/table/e-table.c:
* widgets/text/e-text.c:
Fix various compiler warnings. Patch from Milan Crha.
svn path=/trunk/; revision=34368
Diffstat (limited to 'e-util/e-pilot-map.c')
-rw-r--r-- | e-util/e-pilot-map.c | 109 |
1 files changed, 36 insertions, 73 deletions
diff --git a/e-util/e-pilot-map.c b/e-util/e-pilot-map.c index 6587368773..3276337679 100644 --- a/e-util/e-pilot-map.c +++ b/e-util/e-pilot-map.c @@ -206,39 +206,23 @@ e_pilot_map_uid_is_archived (EPilotMap *map, const char *uid) void e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archived) { - gpointer key, value; - - if (g_hash_table_lookup_extended (map->pid_map, &pid, &key, &value)) { - EPilotMapPidNode *pnode = value; - gpointer other_key, other_value; - - g_hash_table_remove (map->pid_map, &pid); + EPilotMapPidNode *pnode; + EPilotMapUidNode *unode; + pnode = g_hash_table_lookup (map->pid_map, &pid); + if (pnode != NULL) { /* In case the pid<->uid mapping is not the same anymore */ - if (g_hash_table_lookup_extended (map->uid_map, pnode->uid, &other_key, &other_value)) { - g_hash_table_remove (map->uid_map, pnode->uid); - g_free (other_key); - g_free (other_value); - } + g_hash_table_remove (map->uid_map, pnode->uid); - g_free (key); - g_free (value); + g_hash_table_remove (map->pid_map, &pid); } - if (g_hash_table_lookup_extended (map->uid_map, uid, &key, &value)) { - EPilotMapUidNode *unode = value; - gpointer other_key, other_value; - - g_hash_table_remove (map->uid_map, uid); + unode = g_hash_table_lookup (map->uid_map, uid); + if (unode != NULL) { /* In case the pid<->uid mapping is not the same anymore */ - if (g_hash_table_lookup_extended (map->pid_map, &unode->pid, &other_key, &other_value)) { - g_hash_table_remove (map->pid_map, &unode->pid); - g_free (other_key); - g_free (other_value); - } + g_hash_table_remove (map->pid_map, &unode->pid); - g_free (key); - g_free (value); + g_hash_table_remove (map->uid_map, uid); } real_e_pilot_map_insert (map, pid, uid, archived, TRUE); @@ -247,54 +231,39 @@ e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archi void e_pilot_map_remove_by_pid (EPilotMap *map, guint32 pid) { - EPilotMapPidNode *pnode = NULL; - EPilotMapUidNode *unode = NULL; - gpointer pkey, ukey; - + EPilotMapPidNode *pnode; + EPilotMapUidNode *unode; + g_return_if_fail (map != NULL); - if (!g_hash_table_lookup_extended (map->pid_map, &pid, - &pkey, (gpointer *)&pnode)) + pnode = g_hash_table_lookup (map->pid_map, &pid); + if (pnode == NULL) return; - - g_hash_table_lookup_extended (map->uid_map, pnode->uid, &ukey, - (gpointer *)&unode); + + unode = g_hash_table_lookup (map->uid_map, pnode->uid); g_return_if_fail (unode != NULL); - - g_hash_table_remove (map->pid_map, &pid); - g_hash_table_remove (map->uid_map, pnode->uid); - g_free (pkey); - g_free (ukey); - g_free (pnode); - g_free (unode); + g_hash_table_remove (map->uid_map, pnode->uid); + g_hash_table_remove (map->pid_map, &pid); } void e_pilot_map_remove_by_uid (EPilotMap *map, const char *uid) { - EPilotMapPidNode *pnode = NULL; - EPilotMapUidNode *unode = NULL; - gpointer pkey, ukey; - + EPilotMapPidNode *pnode; + EPilotMapUidNode *unode; + g_return_if_fail (map != NULL); g_return_if_fail (uid != NULL); - if (!g_hash_table_lookup_extended (map->uid_map, uid, &ukey, (gpointer *)&unode)) + unode = g_hash_table_lookup (map->uid_map, uid); + if (unode == NULL) return; - g_hash_table_lookup_extended (map->pid_map, &unode->pid, &pkey, (gpointer *)&pnode); + pnode = g_hash_table_lookup (map->pid_map, &unode->pid); - g_hash_table_remove (map->uid_map, uid); g_hash_table_remove (map->pid_map, &unode->pid); - - if (unode->pid != 0) - g_free (pkey); - g_free (ukey); - - if (unode->pid != 0) - g_free (pnode); - g_free (unode); + g_hash_table_remove (map->uid_map, uid); } @@ -363,8 +332,14 @@ e_pilot_map_read (const char *filename, EPilotMap **map) memset (&handler, 0, sizeof (xmlSAXHandler)); handler.startElement = map_sax_start_element; - new_map->pid_map = g_hash_table_new (g_int_hash, g_int_equal); - new_map->uid_map = g_hash_table_new (g_str_hash, g_str_equal); + new_map->pid_map = g_hash_table_new_full ( + g_int_hash, g_int_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_free); + new_map->uid_map = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_free); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { if (xmlSAXUserParseFile (&handler, new_map, filename) < 0) { @@ -416,22 +391,13 @@ e_pilot_map_write (const char *filename, EPilotMap *map) return 0; } -static gboolean -foreach_remove (gpointer key, gpointer value, gpointer data) -{ - g_free (key); - g_free (value); - - return TRUE; -} - void e_pilot_map_clear (EPilotMap *map) { g_return_if_fail (map != NULL); - g_hash_table_foreach_remove (map->pid_map, foreach_remove, NULL); - g_hash_table_foreach_remove (map->uid_map, foreach_remove, NULL); + g_hash_table_remove_all (map->pid_map); + g_hash_table_remove_all (map->uid_map); map->since = 0; map->write_touched_only = FALSE; @@ -442,9 +408,6 @@ e_pilot_map_destroy (EPilotMap *map) { g_return_if_fail (map != NULL); - g_hash_table_foreach_remove (map->pid_map, foreach_remove, NULL); - g_hash_table_foreach_remove (map->uid_map, foreach_remove, NULL); - g_hash_table_destroy (map->pid_map); g_hash_table_destroy (map->uid_map); g_free (map); |