diff options
-rw-r--r-- | camel/ChangeLog | 19 | ||||
-rw-r--r-- | camel/camel-folder.c | 86 | ||||
-rw-r--r-- | camel/camel-vee-folder.c | 2 |
3 files changed, 84 insertions, 23 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index ab5de4a1c2..4a46e9a04a 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,22 @@ +2001-06-18 Jeffrey Stedfast <fejj@ximian.com> + + Note: Except for the info_free(), the NULL checks are + g_return's. I felt that since g_free() handles NULL that our + _free() functions should also. + + * camel-folder.c (camel_folder_change_info_free): Check to make + sure that the info pointer isn't NULL. + (camel_folder_change_info_change_uid): Same. + (camel_folder_change_info_changed): Same. + (camel_folder_change_info_remove_uid): Same. + (camel_folder_change_info_add_uid): Same. + (camel_folder_change_info_build_diff): Same. + (camel_folder_change_info_cat): Same. + (camel_folder_change_info_add_source): Same. + (camel_folder_change_info_add_source_list): Same. + (camel_folder_change_info_add_update): Same. + (camel_folder_change_info_add_update_list): Same. + 2001-06-18 Dan Winship <danw@ximian.com> * tests/stream/Makefile.am (LDADD): diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 671fe75142..736ed2a903 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -1452,8 +1452,12 @@ camel_folder_change_info_new(void) void camel_folder_change_info_add_source(CamelFolderChangeInfo *info, const char *uid) { - struct _CamelFolderChangeInfoPrivate *p = info->priv; - + struct _CamelFolderChangeInfoPrivate *p; + + g_return_if_fail (info != NULL); + + p = info->priv; + if (p->uid_source == NULL) p->uid_source = g_hash_table_new(g_str_hash, g_str_equal); @@ -1471,8 +1475,13 @@ camel_folder_change_info_add_source(CamelFolderChangeInfo *info, const char *uid void camel_folder_change_info_add_source_list(CamelFolderChangeInfo *info, const GPtrArray *list) { + struct _CamelFolderChangeInfoPrivate *p; int i; - struct _CamelFolderChangeInfoPrivate *p = info->priv; + + g_return_if_fail (info != NULL); + g_return_if_fail (list != NULL); + + p = info->priv; if (p->uid_source == NULL) p->uid_source = g_hash_table_new(g_str_hash, g_str_equal); @@ -1495,10 +1504,14 @@ camel_folder_change_info_add_source_list(CamelFolderChangeInfo *info, const GPtr void camel_folder_change_info_add_update(CamelFolderChangeInfo *info, const char *uid) { + struct _CamelFolderChangeInfoPrivate *p; char *key; int value; - struct _CamelFolderChangeInfoPrivate *p = info->priv; - + + g_return_if_fail (info != NULL); + + p = info->priv; + if (p->uid_source == NULL) { camel_folder_change_info_add_uid(info, uid); return; @@ -1522,7 +1535,10 @@ void camel_folder_change_info_add_update_list(CamelFolderChangeInfo *info, const GPtrArray *list) { int i; - + + g_return_if_fail (info != NULL); + g_return_if_fail (list != NULL); + for (i=0;i<list->len;i++) camel_folder_change_info_add_update(info, list->pdata[i]); } @@ -1544,7 +1560,6 @@ change_info_remove(char *key, void *value, CamelFolderChangeInfo *info) return; } - /* we dont need to copy this, as they've already been copied into our pool */ g_ptr_array_add(info->uid_removed, key); g_hash_table_insert(p->uid_stored, key, info->uid_removed); @@ -1560,8 +1575,12 @@ change_info_remove(char *key, void *value, CamelFolderChangeInfo *info) void camel_folder_change_info_build_diff(CamelFolderChangeInfo *info) { - struct _CamelFolderChangeInfoPrivate *p = info->priv; - + struct _CamelFolderChangeInfoPrivate *p; + + g_return_if_fail (info != NULL); + + p = info->priv; + if (p->uid_source) { g_hash_table_foreach(p->uid_source, (GHFunc)change_info_remove, info); g_hash_table_destroy(p->uid_source); @@ -1589,6 +1608,9 @@ change_info_cat(CamelFolderChangeInfo *info, GPtrArray *source, void (*add)(Came void camel_folder_change_info_cat(CamelFolderChangeInfo *info, CamelFolderChangeInfo *source) { + g_return_if_fail (info != NULL); + g_return_if_fail (source != NULL); + change_info_cat(info, source->uid_added, camel_folder_change_info_add_uid); change_info_cat(info, source->uid_removed, camel_folder_change_info_remove_uid); change_info_cat(info, source->uid_changed, camel_folder_change_info_change_uid); @@ -1604,10 +1626,14 @@ camel_folder_change_info_cat(CamelFolderChangeInfo *info, CamelFolderChangeInfo void camel_folder_change_info_add_uid(CamelFolderChangeInfo *info, const char *uid) { - struct _CamelFolderChangeInfoPrivate *p = info->priv; + struct _CamelFolderChangeInfoPrivate *p; GPtrArray *olduids; char *olduid; - + + g_return_if_fail (info != NULL); + + p = info->priv; + if (g_hash_table_lookup_extended(p->uid_stored, uid, (void **)&olduid, (void **)&olduids)) { /* if it was removed then added, promote it to a changed */ /* if it was changed then added, leave as changed */ @@ -1634,10 +1660,14 @@ camel_folder_change_info_add_uid(CamelFolderChangeInfo *info, const char *uid) void camel_folder_change_info_remove_uid(CamelFolderChangeInfo *info, const char *uid) { - struct _CamelFolderChangeInfoPrivate *p = info->priv; + struct _CamelFolderChangeInfoPrivate *p; GPtrArray *olduids; char *olduid; - + + g_return_if_fail (info != NULL); + + p = info->priv; + if (g_hash_table_lookup_extended(p->uid_stored, uid, (void **)&olduid, (void **)&olduids)) { /* if it was added/changed them removed, then remove it */ if (olduids != info->uid_removed) { @@ -1663,10 +1693,14 @@ camel_folder_change_info_remove_uid(CamelFolderChangeInfo *info, const char *uid void camel_folder_change_info_change_uid(CamelFolderChangeInfo *info, const char *uid) { - struct _CamelFolderChangeInfoPrivate *p = info->priv; + struct _CamelFolderChangeInfoPrivate *p; GPtrArray *olduids; char *olduid; - + + g_return_if_fail (info != NULL); + + p = info->priv; + if (g_hash_table_lookup_extended(p->uid_stored, uid, (void **)&olduid, (void **)&olduids)) { /* if we have it already, leave it as that */ return; @@ -1688,6 +1722,8 @@ camel_folder_change_info_change_uid(CamelFolderChangeInfo *info, const char *uid gboolean camel_folder_change_info_changed(CamelFolderChangeInfo *info) { + g_return_val_if_fail (info != NULL, FALSE); + return (info->uid_added->len || info->uid_removed->len || info->uid_changed->len); } @@ -1700,8 +1736,12 @@ camel_folder_change_info_changed(CamelFolderChangeInfo *info) void camel_folder_change_info_clear(CamelFolderChangeInfo *info) { - struct _CamelFolderChangeInfoPrivate *p = info->priv; - + struct _CamelFolderChangeInfoPrivate *p; + + g_return_if_fail (info != NULL); + + p = info->priv; + g_ptr_array_set_size(info->uid_added, 0); g_ptr_array_set_size(info->uid_removed, 0); g_ptr_array_set_size(info->uid_changed, 0); @@ -1723,8 +1763,13 @@ camel_folder_change_info_clear(CamelFolderChangeInfo *info) void camel_folder_change_info_free(CamelFolderChangeInfo *info) { - struct _CamelFolderChangeInfoPrivate *p = info->priv; - + struct _CamelFolderChangeInfoPrivate *p; + + if (info == NULL) + return; + + p = info->priv; + if (p->uid_source) g_hash_table_destroy(p->uid_source); @@ -1737,6 +1782,3 @@ camel_folder_change_info_free(CamelFolderChangeInfo *info) g_ptr_array_free(info->uid_changed, TRUE); g_free(info); } - - - diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index 7fdef39272..bc20ef3d59 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -173,7 +173,7 @@ camel_vee_folder_finalise (CamelObject *obj) g_free(vf->expression); g_free(vf->vname); - + camel_folder_change_info_free(vf->changes); camel_object_unref((CamelObject *)vf->search); camel_object_unref((CamelObject *)((CamelFolder *)vf)->summary); |