Commit b62866d9 authored by Thomas Roessler's avatar Thomas Roessler

Replace safe_free calls by the FREE macro.

parent cd96c344
......@@ -231,6 +231,6 @@ new_aliases:
rfc822_write_address (buf, buflen, AliasTable[t]->addr);
mutt_menuDestroy (&menu);
safe_free ((void **) &AliasTable);
FREE (&AliasTable);
}
......@@ -469,7 +469,7 @@ int mutt_alias_complete (char *s, size_t buflen)
{
a_cur = a_list;
a_list = a_list->next;
safe_free ((void **) &a_cur);
FREE (&a_cur);
}
/* remove any aliases marked for deletion */
......
......@@ -156,13 +156,13 @@ int mutt_compose_attachment (BODY *a)
b->parameter = NULL;
}
if (b->description) {
safe_free ((void **) &a->description);
FREE (&a->description);
a->description = b->description;
b->description = NULL;
}
if (b->form_name)
{
safe_free ((void **) &a->form_name);
FREE (&a->form_name);
a->form_name = b->form_name;
b->form_name = NULL;
}
......@@ -356,9 +356,9 @@ void mutt_check_lookup_list (BODY *b, char *type, int len)
b->filename, type));
}
if (tmp.subtype)
safe_free ((void **) &tmp.subtype);
FREE (&tmp.subtype);
if (tmp.xtype)
safe_free ((void **) &tmp.xtype);
FREE (&tmp.xtype);
}
}
}
......
......@@ -60,14 +60,14 @@ static void destroy_state (struct browser_state *state)
for (c = 0; c < state->entrylen; c++)
{
safe_free ((void **) &((state->entry)[c].name));
safe_free ((void **) &((state->entry)[c].desc));
safe_free ((void **) &((state->entry)[c].st));
FREE (&((state->entry)[c].name));
FREE (&((state->entry)[c].desc));
FREE (&((state->entry)[c].st));
}
#ifdef USE_IMAP
safe_free ((void **) &state->folder);
FREE (&state->folder);
#endif
safe_free ((void **) &state->entry);
FREE (&state->entry);
}
static int browser_compare_subject (const void *a, const void *b)
......@@ -889,8 +889,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
if (!imap_delete_mailbox (Context, mx))
{
/* free the mailbox from the browser */
safe_free ((void **) &((state.entry)[nentry].name));
safe_free ((void **) &((state.entry)[nentry].desc));
FREE (&((state.entry)[nentry].name));
FREE (&((state.entry)[nentry].desc));
/* and move all other entries up */
if (nentry+1 < state.entrylen)
memmove (state.entry + nentry, state.entry + nentry + 1,
......@@ -995,14 +995,14 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
{
regerror (err, rx, buf, sizeof (buf));
regfree (rx);
safe_free ((void **) &rx);
FREE (&rx);
mutt_error ("%s", buf);
}
else
{
mutt_str_replace (&Mask.pattern, buf);
regfree (Mask.rx);
safe_free ((void **) &Mask.rx);
FREE (&Mask.rx);
Mask.rx = rx;
Mask.not = not;
......
......@@ -179,9 +179,9 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
{
for (tmp = &Incoming; *tmp;)
{
safe_free((void **)&((*tmp)->path));
FREE (&((*tmp)->path));
tmp1=(*tmp)->next;
safe_free((void **)tmp);
FREE (tmp);
*tmp=tmp1;
}
return 0;
......@@ -203,9 +203,9 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
{
if(*tmp)
{
safe_free((void **)&((*tmp)->path));
FREE (&((*tmp)->path));
tmp1=(*tmp)->next;
safe_free((void **)tmp);
FREE (tmp);
*tmp=tmp1;
}
continue;
......
......@@ -440,7 +440,7 @@ int mutt_convert_string (char **ps, const char *from, const char *to, int flags)
*ob = '\0';
safe_free ((void **) ps);
FREE (ps);
*ps = buf;
mutt_str_adjust (ps);
......@@ -579,5 +579,5 @@ void fgetconv_close (FGETCONV **_fc)
if (fc->cd != (iconv_t)-1)
iconv_close (fc->cd);
safe_free ((void **) _fc);
FREE (_fc);
}
......@@ -124,8 +124,8 @@ static void mutt_free_color_line(COLOR_LINE **l,
regfree(&tmp->rx);
mutt_pattern_free(&tmp->color_pattern);
safe_free((void **)&tmp->pattern);
safe_free((void **)l);
FREE (&tmp->pattern);
FREE (l);
}
void ci_start_color (void)
......@@ -275,7 +275,7 @@ void mutt_free_color (int fg, int bg)
if (p == ColorList)
{
ColorList = ColorList->next;
safe_free ((void **) &p);
FREE (&p);
return;
}
q = ColorList;
......@@ -284,7 +284,7 @@ void mutt_free_color (int fg, int bg)
if (q->next == p)
{
q->next = p->next;
safe_free ((void **) &p);
FREE (&p);
return;
}
q = q->next;
......
......@@ -463,8 +463,8 @@ static int delete_attachment (MUTTMENU *menu, short *idxlen, int x)
idx[x]->content->next = NULL;
idx[x]->content->parts = NULL;
mutt_free_body (&(idx[x]->content));
safe_free ((void **) &idx[x]->tree);
safe_free ((void **) &idx[x]);
FREE (&idx[x]->tree);
FREE (&idx[x]);
for (; x < *idxlen - 1; x++)
idx[x] = idx[x+1];
menu->max = --(*idxlen);
......@@ -723,7 +723,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
if (idxlen && idx[idxlen - 1]->content->next)
{
for (i = 0; i < idxlen; i++)
safe_free ((void **) &idx[i]);
FREE (&idx[i]);
idxlen = 0;
idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
menu->data = idx;
......@@ -758,7 +758,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
menu->redraw |= REDRAW_INDEX;
}
else
safe_free ((void **) &idx[idxlen]);
FREE (&idx[idxlen]);
menu->redraw |= REDRAW_STATUS;
......@@ -807,7 +807,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
{
error = 1;
mutt_error (_("Unable to attach %s!"), att);
safe_free ((void **) &idx[idxlen]);
FREE (&idx[idxlen]);
}
}
......@@ -861,7 +861,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
if (!ctx->msgcount)
{
mx_close_mailbox (ctx, NULL);
safe_free ((void **) &ctx);
FREE (&ctx);
mutt_error _("No messages in that folder.");
break;
}
......@@ -904,7 +904,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
else
{
mutt_error _("Unable to attach!");
safe_free ((void **) &idx[idxlen]);
FREE (&idx[idxlen]);
}
}
}
......@@ -914,7 +914,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
mx_close_mailbox (Context, NULL);
else
mx_fastclose_mailbox (Context);
safe_free ((void **) &Context);
FREE (&Context);
/* go back to the folder we started from */
Context = this;
......@@ -1166,7 +1166,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
if (!(fp = safe_fopen (fname, "w")))
{
mutt_error (_("Can't create file %s"), fname);
safe_free ((void **) &idx[idxlen]);
FREE (&idx[idxlen]);
continue;
}
fclose (fp);
......@@ -1243,10 +1243,10 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
idx[idxlen]->content->next = NULL;
idx[idxlen]->content->parts = NULL;
mutt_free_body (&idx[idxlen]->content);
safe_free ((void **) &idx[idxlen]->tree);
safe_free ((void **) &idx[idxlen]);
FREE (&idx[idxlen]->tree);
FREE (&idx[idxlen]);
}
safe_free ((void **) &idx);
FREE (&idx);
idxlen = 0;
idxmax = 0;
r = -1;
......@@ -1389,12 +1389,12 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
{
msg->content = idx[0]->content;
for (i = 0; i < idxlen; i++)
safe_free ((void **) &idx[i]);
FREE (&idx[i]);
}
else
msg->content = NULL;
safe_free ((void **) &idx);
FREE (&idx);
return (r);
}
......@@ -261,8 +261,8 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
/* Free in a separate loop to be sure that all headers are freed
* in case of error. */
for (x = 0; x < hdr_count; x++)
safe_free ((void **) &headers[x]);
safe_free ((void **) &headers);
FREE (&headers[x]);
FREE (&headers);
if (error)
return (-1);
......
......@@ -770,7 +770,7 @@ void mutt_signed_handler (BODY *a, STATE *s)
state_attach_puts (_("[-- The following data is signed --]\n\n"), s);
safe_free((void **) &signatures);
FREE (&signatures);
}
else
state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), s);
......
......@@ -481,7 +481,7 @@ int mutt_index_menu (void)
if (!Context->path)
{
/* fatal error occurred */
safe_free ((void **) &Context);
FREE (&Context);
menu->redraw = REDRAW_FULL;
}
......@@ -978,7 +978,7 @@ int mutt_index_menu (void)
/* check for a fatal error, or all messages deleted */
if (!Context->path)
safe_free ((void **) &Context);
FREE (&Context);
/* if we were in the pager, redisplay the message */
if (menu->menu == MENU_PAGER)
......@@ -1038,7 +1038,7 @@ int mutt_index_menu (void)
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
break;
}
safe_free ((void **) &Context);
FREE (&Context);
}
mutt_sleep (0);
......@@ -1109,7 +1109,7 @@ int mutt_index_menu (void)
if (Context)
{
mx_fastclose_mailbox (Context);
safe_free ((void **) &Context);
FREE (&Context);
}
done = 1;
}
......
......@@ -165,7 +165,7 @@ static void replace_part (ENTER_STATE *state, size_t from, char *buf)
memcpy (state->wbuf + state->curpos, savebuf, savelen * sizeof (wchar_t));
state->lastchar = state->curpos + savelen;
safe_free ((void **) &savebuf);
FREE (&savebuf);
}
/*
......@@ -686,7 +686,7 @@ self_insert:
bye:
safe_free ((void **) &tempbuf);
FREE (&tempbuf);
return rv;
}
......@@ -694,8 +694,8 @@ void mutt_free_enter_state (ENTER_STATE **esp)
{
if (!esp) return;
safe_free ((void **) &(*esp)->wbuf);
safe_free ((void **) esp);
FREE (&(*esp)->wbuf);
FREE (esp);
}
/*
......
......@@ -107,7 +107,7 @@ static void fix_uid (char *uid)
else if (ob-buf == n && (buf[n] = 0, strlen (buf) < n))
memcpy (uid, buf, n);
}
safe_free ((void **) &buf);
FREE (&buf);
iconv_close (cd);
}
}
......
......@@ -146,9 +146,9 @@ void hash_destroy (HASH **ptr, void (*destroy) (void *))
elem = elem->next;
if (destroy)
destroy (tmp->data);
safe_free ((void **) &tmp);
FREE (&tmp);
}
}
safe_free ((void **) &pptr->table);
safe_free ((void **) ptr);
FREE (&pptr->table);
FREE (ptr);
}
......@@ -40,8 +40,8 @@ static void init_history (struct history *h)
if (h->hist)
{
for (i = 0 ; i < OldSize ; i ++)
safe_free ((void **) &h->hist[i]);
safe_free ((void **) &h->hist);
FREE (&h->hist[i]);
FREE (&h->hist);
}
}
......
......@@ -165,7 +165,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
regerror (rc, rx, err->data, err->dsize);
regfree (rx);
safe_free ((void **) &rx);
FREE (&rx);
goto error;
}
}
......
......@@ -192,7 +192,7 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
rc = mutt_socket_write_d (idata->conn, out,
flags & IMAP_CMD_PASS ? IMAP_LOG_PASS : IMAP_LOG_CMD);
safe_free ((void**) &out);
FREE (&out);
if (rc < 0)
{
......
......@@ -869,7 +869,7 @@ int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed)
}
}
safe_free ((void**) &hdrs);
FREE (&hdrs);
return count;
}
......@@ -1089,7 +1089,7 @@ void imap_close_mailbox (CONTEXT* ctx)
if (idata->cache[i].path)
{
unlink (idata->cache[i].path);
safe_free ((void **) &idata->cache[i].path);
FREE (&idata->cache[i].path);
}
}
}
......
......@@ -254,7 +254,7 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
cache->path = safe_strdup (path);
if (!(msg->fp = safe_fopen (path, "w+")))
{
safe_free ((void**) &cache->path);
FREE (&cache->path);
return -1;
}
......@@ -676,7 +676,7 @@ void imap_free_header_data (void** data)
/* this should be safe even if the list wasn't used */
mutt_free_list (&(((IMAP_HEADER_DATA*) *data)->keywords));
safe_free (data);
FREE (data);
}
/* imap_set_flags: fill out the message header according to the flags from
......
......@@ -130,7 +130,7 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8,
return buf;
bail:
safe_free ((void **) &buf);
FREE (&buf);
return 0;
}
......@@ -220,7 +220,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
if (u8len)
{
safe_free ((void **) &buf);
FREE (&buf);
return 0;
}
......@@ -239,7 +239,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
return buf;
bail:
safe_free ((void **) &buf);
FREE (&buf);
return 0;
}
......@@ -250,7 +250,7 @@ void imap_utf7_encode (char **s)
char *t = safe_strdup (*s);
if (!mutt_convert_string (&t, Charset, "UTF-8", 0))
utf8_to_utf7 (t, strlen (t), s, 0);
safe_free ((void **) &t);
FREE (&t);
}
}
......@@ -261,7 +261,7 @@ void imap_utf7_decode (char **s)
char *t = utf7_to_utf8 (*s, strlen (*s), 0, 0);
if (t && !mutt_convert_string (&t, "UTF-8", Charset, 0))
{
safe_free ((void **) s);
FREE (s);
*s = t;
}
}
......
......@@ -508,7 +508,7 @@ void imap_munge_mbox_name (char *dest, size_t dlen, const char *src)
imap_quote_string (dest, dlen, buf);
safe_free ((void **) &buf);
FREE (&buf);
}
void imap_unmunge_mbox_name (char *s)
......@@ -524,7 +524,7 @@ void imap_unmunge_mbox_name (char *s)
strncpy (s, buf, strlen (s));
}
safe_free ((void **) &buf);
FREE (&buf);
}
/* imap_wordcasecmp: find word a in word list b */
......
......@@ -342,12 +342,12 @@ static void remove_from_list (LIST **l, const char *str)
{
if (ascii_strcasecmp (str, p->data) == 0)
{
safe_free ((void **) &p->data);
FREE (&p->data);
if (last)
last->next = p->next;
else
(*l) = p->next;
safe_free ((void **) &p);
FREE (&p);
}
else
{
......@@ -611,7 +611,7 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err
if (ascii_strncasecmp (buf->data, tmp->data, keylen) == 0)
{
/* replace the old value */
safe_free ((void **) &tmp->data);
FREE (&tmp->data);
tmp->data = buf->data;
memset (buf, 0, sizeof (BUFFER));
return 0;
......@@ -902,7 +902,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
if (DTYPE (MuttVars[idx].type) == DT_ADDR)
rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
else
safe_free ((void **) MuttVars[idx].data);
FREE (MuttVars[idx].data);
}
else if (query || *s->dptr != '=')
{
......@@ -1273,7 +1273,7 @@ static int source_rc (const char *rcfile, BUFFER *err)
rc = -1;
}
FREE (&token.data);
safe_free ((void **) &linebuf);
FREE (&linebuf);
fclose (f);
if (pid != -1)
mutt_wait_filter (pid);
......
......@@ -145,7 +145,7 @@ char *safe_strdup (const char *s)
void mutt_str_replace (char **p, const char *s)
{
safe_free ((void **) p);
FREE (p);
*p = safe_strdup (s);
}
......@@ -451,7 +451,7 @@ char *mutt_read_line (char *s, size_t *size, FILE *fp, int *line)
{
if (fgets (s + offset, *size - offset, fp) == NULL)
{
safe_free ((void **) &s);
FREE (&s);
return NULL;
}
if ((ch = strchr (s + offset, '\n')) != NULL)
......
......@@ -797,7 +797,7 @@ int main (int argc, char **argv)
}
}
safe_free ((void **) &bodytext);
FREE (&bodytext);
if (attach)
{
......@@ -885,7 +885,7 @@ int main (int argc, char **argv)
{
mutt_index_menu ();
if (Context)
safe_free ((void **)&Context);
FREE (&Context);
}
mutt_endwin (Errorbuf);
}
......
......@@ -991,8 +991,8 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
ctx->hdrs[i]->index = j++;
}
}
safe_free ((void **) &newOffset);
safe_free ((void **) &oldOffset);
FREE (&newOffset);
FREE (&oldOffset);
unlink (tempfile); /* remove partial copy of the mailbox */
mutt_unblock_signals ();
Sort = save_sort; /* Restore the default value. */
......@@ -1020,8 +1020,8 @@ bail: /* Come here in case of disaster */
mbox_unlock_mailbox (ctx);
mutt_unblock_signals ();
safe_free ((void **) &newOffset);
safe_free ((void **) &oldOffset);
FREE (&newOffset);
FREE (&oldOffset);
if ((ctx->fp = freopen (ctx->path, "r", ctx->fp)) == NULL)
{
......@@ -1085,12 +1085,12 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
if (ctx->subj_hash)
hash_destroy (&ctx->subj_hash, NULL);
mutt_clear_threads (ctx);
safe_free ((void **) &ctx->v2r);
FREE (&ctx->v2r);
if (ctx->readonly)
{
for (i = 0; i < ctx->msgcount; i++)
mutt_free_header (&(ctx->hdrs[i])); /* nothing to do! */
safe_free ((void **) &ctx->hdrs);
FREE (&ctx->hdrs);
}
else
{
......@@ -1140,7 +1140,7 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
/* free the old headers */
for (j = 0; j < old_msgcount; j++)
mutt_free_header (&(old_hdrs[j]));
safe_free ((void **) &old_hdrs);
FREE (&old_hdrs);
ctx->quiet = 0;
return (-1);
......@@ -1219,7 +1219,7 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
msg_mod = 1;
}
}
safe_free ((void **) &old_hdrs);
FREE (&old_hdrs);
}
ctx->quiet = 0;
......
......@@ -683,17 +683,17 @@ void mutt_menuDestroy (MUTTMENU **p)
{
int i;
safe_free ((void **) &(*p)->searchBuf);
FREE (&(*p)->searchBuf);
if ((*p)->dialog)
{
for (i=0; i < (*p)->max; i++)
safe_free ((void **) &(*p)->dialog[i]);
FREE (&(*p)->dialog[i]);
safe_free ((void **) (*p)->dialog);
FREE ((*p)->dialog);
}
safe_free ((void **) p);
FREE (p);
}
#define M_SEARCH_UP 1
......
......@@ -81,7 +81,7 @@ static void mhs_alloc (struct mh_sequences *mhs, int i)
static void mhs_free_sequences (struct mh_sequences *mhs)
{
safe_free ((void **) &mhs->flags);
FREE (&mhs->flags);
}
static short mhs_check (struct mh_sequences *mhs, int i)
......@@ -164,7 +164,7 @@ static void mh_read_sequences (struct mh_sequences *mhs, const char *path)
}
}
safe_free ((void **) &buff);
FREE (&buff);
safe_fclose (&fp);
}
......@@ -366,7 +366,7 @@ void mh_update_sequences (CONTEXT * ctx)
unlink (tmpfname);
}
safe_free ((void **) &tmpfname);
FREE (&tmpfname);
}
static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen,
......@@ -423,7 +423,7 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen,
}
}
safe_fclose (&ofp);
safe_free ((void **) &buff);
FREE (&buff);
if (!unseen_done && unseen)
fprintf (nfp, "%s: %d\n", NONULL (MhUnseen), n);
......@@ -438,7 +438,7 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen,
if (safe_rename (tmpfname, sequences) != 0)
unlink (tmpfname);
safe_free ((void **) &tmpfname);
FREE (&tmpfname);
}
static void mh_update_maildir (struct maildir *md, struct mh_sequences *mhs)
......@@ -470,11 +470,11 @@ static void maildir_free_entry (struct maildir **md)
if (!md || !*md)
return;
safe_free ((void **) &(*md)->canon_fname);
FREE (&(*md)->canon_fname);
if ((*md)->h)
mutt_free_header (&(*md)->h);
safe_free ((void **) md);
FREE (md);
}
static void maildir_free_maildir (struct maildir **md)
......@@ -539,7 +539,7 @@ static void maildir_parse_flags (HEADER * h, const char *path)
}
if (q == h->maildir_flags)
safe_free ((void **) &h->maildir_flags);