summaryrefslogtreecommitdiffstats
path: root/mh.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2000-01-10 10:35:48 +0000
committerThomas Roessler <roessler@does-not-exist.org>2000-01-10 10:35:48 +0000
commit544e8ba393e9c1ca55b120f209383742211007c8 (patch)
tree5157baa0f2071aa0763254491475416832cdf991 /mh.c
parentc8e19c984e900ede0f0c09353a96c62a6aa81445 (diff)
Add (and use) a function mutt_str_replace, which essentially
replaces the sequence: safe_free (&s); s = safe_strdup (t);
Diffstat (limited to 'mh.c')
-rw-r--r--mh.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/mh.c b/mh.c
index a4d66787..a4805978 100644
--- a/mh.c
+++ b/mh.c
@@ -500,10 +500,7 @@ int maildir_commit_message (CONTEXT *ctx, MESSAGE *msg, HEADER *hdr)
if (safe_rename (msg->path, full) == 0)
{
if (hdr)
- {
- FREE (&hdr->path);
- hdr->path = safe_strdup (path);
- }
+ mutt_str_replace (&hdr->path, path);
FREE (&msg->path);
return 0;
}
@@ -575,10 +572,7 @@ int mh_commit_message (CONTEXT *ctx, MESSAGE *msg, HEADER *hdr)
if (safe_rename (msg->path, path) == 0)
{
if (hdr)
- {
- FREE (&hdr->path);
- hdr->path = safe_strdup (tmp);
- }
+ mutt_str_replace (&hdr->path, tmp);
FREE (&msg->path);
return 0;
}
@@ -648,10 +642,7 @@ static int mh_sync_message (CONTEXT *ctx, int msgno)
{
snprintf (newpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
if ((rc = safe_rename (newpath, oldpath)) == 0)
- {
- FREE (&h->path);
- h->path = safe_strdup (partpath);
- }
+ mutt_str_replace (&h->path, partpath);
}
}
else mx_close_message (&dest);
@@ -719,8 +710,7 @@ static int maildir_sync_message (CONTEXT *ctx, int msgno)
mutt_perror ("rename");
return (-1);
}
- safe_free ((void **) &h->path);
- h->path = safe_strdup (partpath);
+ mutt_str_replace (&h->path, partpath);
}
return (0);
}
@@ -928,10 +918,7 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
ctx->hdrs[i]->read ? "R" : ""));
if(mutt_strcmp(ctx->hdrs[i]->path, p->h->path))
- {
- safe_free((void **) &ctx->hdrs[i]->path);
- ctx->hdrs[i]->path = safe_strdup(p->h->path);
- }
+ mutt_str_replace (&ctx->hdrs[i]->path, p->h->path);
if(modified)
{