# include "config.h"
#endif
+#include <lib-lib/mem.h>
+#include <lib-lib/macros.h>
+
#include "mutt.h"
#include "buffy.h"
#include "ascii.h"
#include "mutt_crypt.h"
-#include "lib/mem.h"
-#include "lib/intl.h"
#include "lib/str.h"
#include "lib/list.h"
#include "lib/debug.h"
int mx_unlock_file (const char *path, int fd, int dot)
{
#ifdef USE_FCNTL
- struct flock unlockit = { F_UNLCK, 0, 0, 0 };
+ struct flock unlockit;
memset (&unlockit, 0, sizeof (struct flock));
unlockit.l_type = F_UNLCK;
int rc;
if (!ctx)
- ctx = mem_malloc (sizeof (CONTEXT));
- memset (ctx, 0, sizeof (CONTEXT));
+ ctx = p_new(CONTEXT, 1);
+ p_clear(ctx, 1);
ctx->path = str_dup (path);
ctx->msgnotreadyet = -1;
if (mx_open_mailbox_append (ctx, flags) != 0) {
mx_fastclose_mailbox (ctx);
if (!pctx)
- mem_free (&ctx);
+ p_delete(&ctx);
return NULL;
}
return ctx;
if (ctx->magic <= 0) {
mx_fastclose_mailbox (ctx);
if (!pctx)
- mem_free (&ctx);
+ p_delete(&ctx);
return (NULL);
}
else {
mx_fastclose_mailbox (ctx);
if (!pctx)
- mem_free (&ctx);
+ p_delete(&ctx);
}
unset_option (OPTFORCEREFRESH);
mutt_clear_threads (ctx);
for (i = 0; i < ctx->msgcount; i++)
mutt_free_header (&ctx->hdrs[i]);
- mem_free (&ctx->hdrs);
- mem_free (&ctx->v2r);
+ p_delete(&ctx->hdrs);
+ p_delete(&ctx->v2r);
#ifdef USE_COMPRESSED
if (ctx->compressinfo)
mutt_fast_close_compressed (ctx);
#endif
- mem_free (&ctx->path);
- mem_free (&ctx->pattern);
+ p_delete(&ctx->path);
+ p_delete(&ctx->pattern);
if (ctx->limit_pattern)
mutt_pattern_free (&ctx->limit_pattern);
safe_fclose (&ctx->fp);
}
/* save changes and close mailbox */
-int mx_close_mailbox (CONTEXT * ctx, int *index_hint)
+static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint)
{
int i, move_messages = 0, purge = 1, read_msgs = 0;
int check;
return 0;
}
+int mx_close_mailbox (CONTEXT * ctx, int *index_hint) {
+ int ret = 0;
+ if (!ctx)
+ return (0);
+ ret = _mx_close_mailbox (ctx, index_hint);
+ sidebar_set_buffystats (ctx);
+ return (ret);
+}
/* update a Context structure's internal tables. */
* 0 success
* -1 error
*/
-int mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
+static int _mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
{
int rc, i;
int purge = 1;
return 0;
}
- /* update sidebar counts */
- sidebar_set_buffystats (ctx);
-
/* if we haven't deleted any messages, we don't need to resort */
/* ... except for certain folder formats which need "unsorted"
* sort order in order to synchronize folders.
return (rc);
}
+int mx_sync_mailbox (CONTEXT* ctx, int* index_hint) {
+ int ret = _mx_sync_mailbox (ctx, index_hint);
+ sidebar_set_buffystats (ctx);
+ return (ret);
+}
+
/* args:
* dest destintation mailbox
* hdr message being copied (required for maildir support, because
return (NULL);
}
- msg = mem_calloc (1, sizeof (MESSAGE));
+ msg = p_new(MESSAGE, 1);
msg->magic = dest->magic;
msg->write = 1;
}
}
else
- mem_free (&msg);
+ p_delete(&msg);
return msg;
}
{
MESSAGE *msg;
- msg = mem_calloc (1, sizeof (MESSAGE));
+ msg = p_new(MESSAGE, 1);
switch (msg->magic = ctx->magic) {
case M_MBOX:
case M_MMDF:
if (msg->fp == NULL) {
mutt_perror (path);
debug_print (1, ("fopen: %s: %s (errno %d).\n", path, strerror (errno), errno));
- mem_free (&msg);
+ p_delete(&msg);
}
}
break;
case M_IMAP:
{
if (imap_fetch_message (msg, ctx, msgno) != 0)
- mem_free (&msg);
+ p_delete(&msg);
break;
}
#endif /* USE_IMAP */
case M_POP:
{
if (pop_fetch_message (msg, ctx, msgno) != 0)
- mem_free (&msg);
+ p_delete(&msg);
break;
}
#endif /* USE_POP */
case M_NNTP:
{
if (nntp_fetch_message (msg, ctx, msgno) != 0)
- mem_free (&msg);
+ p_delete(&msg);
break;
}
#endif /* USE_NNTP */
default:
debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic));
- mem_free (&msg);
+ p_delete(&msg);
break;
}
return (msg);
if ((*msg)->path) {
debug_print (1, ("unlinking %s\n", (*msg)->path));
unlink ((*msg)->path);
- mem_free (&(*msg)->path);
+ p_delete(&(*msg)->path);
}
- mem_free (msg);
+ p_delete(msg);
return (r);
}
}
if (ctx->hdrs) {
- mem_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25));
- mem_realloc (&ctx->v2r, sizeof (int) * ctx->hdrmax);
+ p_realloc(&ctx->hdrs, ctx->hdrmax += 25);
+ p_realloc(&ctx->v2r, ctx->hdrmax);
}
else {
- ctx->hdrs = mem_calloc ((ctx->hdrmax += 25), sizeof (HEADER *));
- ctx->v2r = mem_calloc (ctx->hdrmax, sizeof (int));
+ ctx->hdrs = p_new(HEADER *, (ctx->hdrmax += 25));
+ ctx->v2r = p_new(int, ctx->hdrmax);
}
for (i = ctx->msgcount; i < ctx->hdrmax; i++) {
ctx->hdrs[i] = NULL;
h2 = hash_find (ctx->id_hash, h->env->supersedes);
- /* mem_free (&h->env->supersedes); should I ? */
+ /* p_delete(&h->env->supersedes); should I ? */
if (h2) {
h2->superseded = 1;
if (!ctx->counting && option (OPTSCORE))
#endif
)
continue;
+ sidebar_set_current (b->path);
+ sidebar_draw (CurrentMenu);
if ((ctx = mx_open_mailbox (b->path,
M_READONLY | M_NOSORT | M_COUNT,
NULL)) != NULL)
}
mutt_clear_error ();
+ if (Context && Context->path)
+ sidebar_set_current (Context->path);
+ sidebar_draw (CurrentMenu);
+
return (0);
#endif
}