2007-08-22 [colin] 2.10.0cvs154
[claws.git] / src / msgcache.c
index b35346deb49c09df99dd1bc723a47422cadfa2b2..20b0d9befae5a22b60e3875050fddddb11e87bfb 100644 (file)
@@ -324,7 +324,7 @@ gint msgcache_get_memory_usage(MsgCache *cache)
 { \
        GET_CACHE_DATA_INT(tmp_len);    \
        if ((tmp_len = msgcache_get_cache_data_str(walk_data, &data, tmp_len, conv)) < 0) { \
-               printf("error at rem_len:%d\n", rem_len);\
+               g_print("error at rem_len:%d\n", rem_len);\
                procmsg_msginfo_free(msginfo); \
                error = TRUE; \
                goto bail_err; \
@@ -395,7 +395,7 @@ static FILE *msgcache_open_data_file(const gchar *file, guint version,
 
        if (mode == DATA_WRITE) {
                int w_err = 0, wrote = 0;
-               if ((fp = g_fopen(file, "w+")) == NULL) {
+               if ((fp = g_fopen(file, "wb")) == NULL) {
                        FILE_OP_ERROR(file, "fopen");
                        return NULL;
                }
@@ -478,7 +478,6 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str,
        tmpstr = g_try_malloc(len + 1);
 
        if(tmpstr == NULL) {
-               g_warning("read_data_str: can't g_malloc %d bytes - cache data probably corrupted.\n", len);
                return -1;
        }
 
@@ -518,7 +517,6 @@ static gint msgcache_get_cache_data_str(gchar *src, gchar **str, gint len,
        tmpstr = g_try_malloc(len + 1);
 
        if(tmpstr == NULL) {
-               g_warning("read_data_str: can't g_malloc %d bytes - cache data probably corrupted.\n", len);
                return -1;
        }
 
@@ -640,6 +638,7 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
                        if (!hMapping)
                                goto w32_fail;
                        cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
+                       CloseHandle (hMapping);
                w32_fail:
                        ;
 #else
@@ -822,6 +821,7 @@ void msgcache_read_mark(MsgCache *cache, const gchar *mark_file)
                        if (!hMapping)
                                goto w32_fail2;
                        cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
+                       CloseHandle (hMapping);
                w32_fail2:
                        ;
 #else
@@ -905,6 +905,7 @@ void msgcache_read_tags(MsgCache *cache, const gchar *tags_file)
                        if (!hMapping)
                                goto w32_fail6;
                        cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
+                       CloseHandle (hMapping);
                w32_fail6:
                        ;
 #else
@@ -1240,6 +1241,7 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
                        if (!hMapping)
                                goto w32_fail3;
                        cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
+                       CloseHandle (hMapping);
                w32_fail3:
                        ;
 #else
@@ -1259,6 +1261,7 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
                                if (!hMapping)
                                        goto w32_fail4;
                                mark_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
+                               CloseHandle (hMapping);
                        w32_fail4:
                                ;
 #else
@@ -1285,6 +1288,7 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
                                                if (!hMapping)
                                                        goto w32_fail5;
                                                tags_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
+                                               CloseHandle (hMapping);
                                        w32_fail5:
                                                ;
 #else