X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mx.c;h=27947b4b1847e87979ad56bff3b1e35e00d0b5d7;hp=e7a4db97dd6f37f8387b3efd307975775636664d;hb=169f101dc43f0581d8c52bcf8131d9eecb7cdeb0;hpb=a8477ebaa09990b3688164cbe5cf661c4189541d diff --git a/mx.c b/mx.c index e7a4db9..27947b4 100644 --- a/mx.c +++ b/mx.c @@ -13,11 +13,13 @@ #endif #include "mutt.h" +#include "ascii.h" #include "mx.h" #include "mbox.h" #include "mh.h" #include "rfc2047.h" #include "sort.h" +#include "thread.h" #include "copy.h" #include "keymap.h" #include "url.h" @@ -199,6 +201,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) count = 0; attempt = 0; + prev_sb.st_size = 0; while (fcntl (fd, F_SETLK, &lck) == -1) { struct stat sb; @@ -518,7 +521,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) int rc; if (!ctx) - ctx = safe_malloc (sizeof (CONTEXT)); + ctx = mem_malloc (sizeof (CONTEXT)); memset (ctx, 0, sizeof (CONTEXT)); ctx->path = str_dup (path); @@ -536,7 +539,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) if (mx_open_mailbox_append (ctx, flags) != 0) { mx_fastclose_mailbox (ctx); if (!pctx) - FREE (&ctx); + mem_free (&ctx); return NULL; } return ctx; @@ -559,7 +562,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) if (ctx->magic <= 0) { mx_fastclose_mailbox (ctx); if (!pctx) - FREE (&ctx); + mem_free (&ctx); return (NULL); } @@ -589,7 +592,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) else { mx_fastclose_mailbox (ctx); if (!pctx) - FREE (&ctx); + mem_free (&ctx); } unset_option (OPTFORCEREFRESH); @@ -613,14 +616,14 @@ void mx_fastclose_mailbox (CONTEXT * ctx) mutt_clear_threads (ctx); for (i = 0; i < ctx->msgcount; i++) mutt_free_header (&ctx->hdrs[i]); - FREE (&ctx->hdrs); - FREE (&ctx->v2r); + mem_free (&ctx->hdrs); + mem_free (&ctx->v2r); #ifdef USE_COMPRESSED if (ctx->compressinfo) mutt_fast_close_compressed (ctx); #endif - FREE (&ctx->path); - FREE (&ctx->pattern); + mem_free (&ctx->path); + mem_free (&ctx->pattern); if (ctx->limit_pattern) mutt_pattern_free (&ctx->limit_pattern); safe_fclose (&ctx->fp); @@ -1117,7 +1120,7 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) return (NULL); } - msg = safe_calloc (1, sizeof (MESSAGE)); + msg = mem_calloc (1, sizeof (MESSAGE)); msg->magic = dest->magic; msg->write = 1; @@ -1150,7 +1153,7 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) } } else - FREE (&msg); + mem_free (&msg); return msg; } @@ -1179,7 +1182,7 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) { MESSAGE *msg; - msg = safe_calloc (1, sizeof (MESSAGE)); + msg = mem_calloc (1, sizeof (MESSAGE)); switch (msg->magic = ctx->magic) { case M_MBOX: case M_MMDF: @@ -1201,7 +1204,7 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) if (msg->fp == NULL) { mutt_perror (path); debug_print (1, ("fopen: %s: %s (errno %d).\n", path, strerror (errno), errno)); - FREE (&msg); + mem_free (&msg); } } break; @@ -1210,7 +1213,7 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) case M_IMAP: { if (imap_fetch_message (msg, ctx, msgno) != 0) - FREE (&msg); + mem_free (&msg); break; } #endif /* USE_IMAP */ @@ -1219,7 +1222,7 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) case M_POP: { if (pop_fetch_message (msg, ctx, msgno) != 0) - FREE (&msg); + mem_free (&msg); break; } #endif /* USE_POP */ @@ -1228,14 +1231,14 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) case M_NNTP: { if (nntp_fetch_message (msg, ctx, msgno) != 0) - FREE (&msg); + mem_free (&msg); break; } #endif /* USE_NNTP */ default: debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic)); - FREE (&msg); + mem_free (&msg); break; } return (msg); @@ -1277,10 +1280,10 @@ int mx_close_message (MESSAGE ** msg) if ((*msg)->path) { debug_print (1, ("unlinking %s\n", (*msg)->path)); unlink ((*msg)->path); - FREE (&(*msg)->path); + mem_free (&(*msg)->path); } - FREE (msg); + mem_free (msg); return (r); } @@ -1297,12 +1300,12 @@ void mx_alloc_memory (CONTEXT * ctx) } if (ctx->hdrs) { - safe_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25)); - safe_realloc (&ctx->v2r, sizeof (int) * ctx->hdrmax); + mem_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25)); + mem_realloc (&ctx->v2r, sizeof (int) * ctx->hdrmax); } else { - ctx->hdrs = safe_calloc ((ctx->hdrmax += 25), sizeof (HEADER *)); - ctx->v2r = safe_calloc (ctx->hdrmax, sizeof (int)); + ctx->hdrs = mem_calloc ((ctx->hdrmax += 25), sizeof (HEADER *)); + ctx->v2r = mem_calloc (ctx->hdrmax, sizeof (int)); } for (i = ctx->msgcount; i < ctx->hdrmax; i++) { ctx->hdrs[i] = NULL; @@ -1342,7 +1345,7 @@ void mx_update_context (CONTEXT * ctx, int new_messages) h2 = hash_find (ctx->id_hash, h->env->supersedes); - /* FREE (&h->env->supersedes); should I ? */ + /* mem_free (&h->env->supersedes); should I ? */ if (h2) { h2->superseded = 1; if (!ctx->counting && option (OPTSCORE))