#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include "defs.h"
if(msginfo->msgid)
g_hash_table_remove(cache->msgid_table, msginfo->msgid);
g_hash_table_remove(cache->msgnum_table, &msginfo->msgnum);
+
+ msginfo->folder->cache_dirty = TRUE;
+
procmsg_msginfo_free(msginfo);
cache->last_access = time(NULL);
- msginfo->folder->cache_dirty = TRUE;
debug_print("Cache size: %d messages, %u bytes\n", g_hash_table_size(cache->msgnum_table), cache->memusage);
}
if(msginfo->msgid)
g_hash_table_insert(cache->msgid_table, msginfo->msgid, msginfo);
}
-
-#ifdef G_OS_WIN32
- UnmapViewOfFile((void*) cache_data);
-#else
- munmap(cache_data, map_len);
-#endif
} else {
while (fread(&num, sizeof(num), 1, fp) == 1) {
if (swapping)
}
}
bail_err:
+ if (cache_data != NULL && cache_data != MAP_FAILED) {
+#ifdef G_OS_WIN32
+ UnmapViewOfFile((void*) cache_data);
+#else
+ munmap(cache_data, map_len);
+#endif
+ }
fclose(fp);
-
if (conv != NULL) {
if (conv->free != NULL)
conv->free(conv);
gint map_len = -1;
char *cache_data = NULL;
struct stat st;
- gboolean error;
+ gboolean error = FALSE;
swapping = TRUE;
msginfo->flags.perm_flags = perm_flags;
}
}
-#ifdef G_OS_WIN32
- UnmapViewOfFile((void*) cache_data);
-#else
- munmap(cache_data, map_len);
-#endif
} else {
while (fread(&num, sizeof(num), 1, fp) == 1) {
if (swapping)
num = bswap_32(num);
- if (fread(&perm_flags, sizeof(perm_flags), 1, fp) != 1) break;
+ if (fread(&perm_flags, sizeof(perm_flags), 1, fp) != 1) {
+ error = TRUE;
+ break;
+ }
if (swapping)
perm_flags = bswap_32(perm_flags);
msginfo = g_hash_table_lookup(cache->msgnum_table, &num);
}
}
bail_err:
+ if (cache_data != NULL && cache_data != MAP_FAILED) {
+#ifdef G_OS_WIN32
+ UnmapViewOfFile((void*) cache_data);
+#else
+ munmap(cache_data, map_len);
+#endif
+ }
fclose(fp);
+ if (error) {
+ debug_print("error reading cache mark from %s\n", mark_file);
+ }
}
void msgcache_read_tags(MsgCache *cache, const gchar *tags_file)
msginfo->tags = g_slist_reverse(msginfo->tags);
}
}
-#ifdef G_OS_WIN32
- UnmapViewOfFile((void*) cache_data);
-#else
- munmap(cache_data, map_len);
-#endif
} else {
while (fread(&num, sizeof(num), 1, fp) == 1) {
gint id = -1;
}
}
bail_err:
+ if (cache_data != NULL && cache_data != MAP_FAILED) {
+#ifdef G_OS_WIN32
+ UnmapViewOfFile((void*) cache_data);
+#else
+ munmap(cache_data, map_len);
+#endif
+ }
fclose(fp);
+ if (error) {
+ debug_print("error reading cache tags from %s\n", tags_file);
+ }
}
static int msgcache_write_cache(MsgInfo *msginfo, FILE *fp)
if (w_err != 0) {
g_warning("failed to write charset\n");
- fclose(write_fps.cache_fp);
+ if (write_fps.cache_fp)
+ fclose(write_fps.cache_fp);
claws_unlink(new_cache);
g_free(new_cache);
g_free(new_mark);
write_fps.mark_fp = msgcache_open_data_file(new_mark, MARK_VERSION,
DATA_WRITE, NULL, 0);
if (write_fps.mark_fp == NULL) {
- fclose(write_fps.cache_fp);
+ if (write_fps.cache_fp)
+ fclose(write_fps.cache_fp);
claws_unlink(new_cache);
g_free(new_cache);
g_free(new_mark);
write_fps.tags_fp = msgcache_open_data_file(new_tags, TAGS_VERSION,
DATA_WRITE, NULL, 0);
if (write_fps.tags_fp == NULL) {
- fclose(write_fps.cache_fp);
- fclose(write_fps.mark_fp);
+ if (write_fps.cache_fp)
+ fclose(write_fps.cache_fp);
+ if (write_fps.mark_fp)
+ fclose(write_fps.mark_fp);
claws_unlink(new_cache);
claws_unlink(new_mark);
g_free(new_cache);