From ba5e3af4ea19e1d20c80941c077039871ec84258 Mon Sep 17 00:00:00 2001 From: pdmef Date: Mon, 8 Aug 2005 10:35:25 +0000 Subject: [PATCH] Rocco Rutte: - repair string library function naming fuckup once and for all, see updated doc/devel-notes.txt git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@380 e385b8ad-14ed-0310-8656-cc95a2468c6d --- addrbook.c | 4 +- alias.c | 10 ++--- attach.c | 10 ++--- browser.c | 44 ++++++++++---------- buffy.c | 6 +-- charset.c | 22 +++++----- color.c | 16 ++++---- commands.c | 6 +-- compose.c | 56 ++++++++++++------------- compress.c | 42 +++++++++---------- copy.c | 28 ++++++------- crypt-gpgme.c | 88 +++++++++++++++++++-------------------- crypt-mod.c | 2 +- crypt.c | 4 +- curs_lib.c | 10 ++--- curs_main.c | 14 +++---- edit.c | 16 ++++---- enter.c | 22 +++++----- gnupgparse.c | 8 ++-- handler.c | 24 +++++------ hash.c | 22 +++++----- hcache.c | 68 +++++++++++++++---------------- history.c | 6 +-- hook.c | 44 ++++++++++---------- imap/auth.c | 4 +- imap/auth_sasl.c | 2 +- imap/browse.c | 22 +++++----- imap/command.c | 14 +++---- imap/imap.c | 60 +++++++++++++-------------- imap/message.c | 36 ++++++++-------- imap/mx_imap.c | 2 +- imap/utf7.c | 18 ++++---- imap/util.c | 26 ++++++------ init.c | 102 +++++++++++++++++++++++----------------------- intl/dcigettext.c | 10 ++--- intl/plural.c | 24 +++++------ keymap.c | 20 ++++----- lib.c | 6 +-- lib/list.c | 20 ++++----- lib/mem.c | 16 ++++---- lib/mem.h | 17 ++++---- lib/rx.c | 10 ++--- lib/str.c | 8 ++-- main.c | 6 +-- mbox.c | 22 +++++----- menu.c | 14 +++---- mh.c | 34 ++++++++-------- mutt.h | 4 +- mutt_idna.c | 44 ++++++++++---------- mutt_libesmtp.c | 2 +- mutt_sasl.c | 14 +++---- mutt_socket.c | 12 +++--- mutt_ssl.c | 16 ++++---- mutt_ssl_gnutls.c | 22 +++++----- mutt_tunnel.c | 4 +- muttlib.c | 98 ++++++++++++++++++++++---------------------- mx.c | 46 ++++++++++----------- nntp/mx_nntp.c | 2 +- nntp/newsrc.c | 56 ++++++++++++------------- nntp/nntp.c | 58 +++++++++++++------------- pager.c | 60 +++++++++++++-------------- parse.c | 28 ++++++------- pattern.c | 26 ++++++------ pgp.c | 8 ++-- pgpkey.c | 8 ++-- pgplib.c | 12 +++--- pgplib.h | 2 +- pgppacket.c | 4 +- pgppubring.c | 16 ++++---- pop/mx_pop.c | 2 +- pop/pop.c | 20 ++++----- pop/pop_auth.c | 6 +-- pop/pop_lib.c | 16 ++++---- postpone.c | 12 +++--- protos.h | 10 ++--- query.c | 28 ++++++------- recvattach.c | 16 ++++---- recvcmd.c | 2 +- regex.c | 102 +++++++++++++++++++++++----------------------- remailer.c | 22 +++++----- rfc1524.c | 38 ++++++++--------- rfc2047.c | 52 +++++++++++------------ rfc2231.c | 22 +++++----- rfc822.c | 12 +++--- score.c | 10 ++--- send.c | 26 ++++++------ sendlib.c | 74 ++++++++++++++++----------------- sidebar.c | 4 +- smime.c | 26 ++++++------ thread.c | 26 ++++++------ url.c | 2 +- 91 files changed, 1067 insertions(+), 1068 deletions(-) diff --git a/addrbook.c b/addrbook.c index 7528a14..16c147f 100644 --- a/addrbook.c +++ b/addrbook.c @@ -164,7 +164,7 @@ new_aliases: menu->max++; } - safe_realloc (&AliasTable, menu->max * sizeof (ALIAS *)); + mem_realloc (&AliasTable, menu->max * sizeof (ALIAS *)); menu->data = AliasTable; for (i = omax, aliasp = aliases; aliasp; aliasp = aliasp->next, i++) { @@ -228,6 +228,6 @@ new_aliases: } mutt_menuDestroy (&menu); - FREE (&AliasTable); + mem_free (&AliasTable); } diff --git a/alias.c b/alias.c index 9005f48..5a58449 100644 --- a/alias.c +++ b/alias.c @@ -57,7 +57,7 @@ static ADDRESS *mutt_expand_aliases_r (ADDRESS * a, LIST ** expn) } if (!i) { - u = safe_malloc (sizeof (LIST)); + u = mem_malloc (sizeof (LIST)); u->data = str_dup (a->mailbox); u->next = *expn; *expn = u; @@ -238,7 +238,7 @@ retry_name: } } - new = safe_calloc (1, sizeof (ALIAS)); + new = mem_calloc (1, sizeof (ALIAS)); new->self = new; new->name = str_dup (buf); @@ -414,9 +414,9 @@ int mutt_alias_complete (char *s, size_t buflen) while (a) { if (a->name && (strstr (a->name, s) == a->name)) { if (!a_list) /* init */ - a_cur = a_list = (ALIAS *) safe_malloc (sizeof (ALIAS)); + a_cur = a_list = (ALIAS *) mem_malloc (sizeof (ALIAS)); else { - a_cur->next = (ALIAS *) safe_malloc (sizeof (ALIAS)); + a_cur->next = (ALIAS *) mem_malloc (sizeof (ALIAS)); a_cur = a_cur->next; } memcpy (a_cur, a, sizeof (ALIAS)); @@ -436,7 +436,7 @@ int mutt_alias_complete (char *s, size_t buflen) while (a_list) { a_cur = a_list; a_list = a_list->next; - FREE (&a_cur); + mem_free (&a_cur); } /* remove any aliases marked for deletion */ diff --git a/attach.c b/attach.c index c87f9cf..33eacb1 100644 --- a/attach.c +++ b/attach.c @@ -141,12 +141,12 @@ int mutt_compose_attachment (BODY * a) b->parameter = NULL; } if (b->description) { - FREE (&a->description); + mem_free (&a->description); a->description = b->description; b->description = NULL; } if (b->form_name) { - FREE (&a->form_name); + mem_free (&a->form_name); a->form_name = b->form_name; b->form_name = NULL; } @@ -329,9 +329,9 @@ void mutt_check_lookup_list (BODY * b, char *type, int len) debug_print (1, ("\"%s\" -> %s\n", b->filename, type)); } if (tmp.subtype) - FREE (&tmp.subtype); + mem_free (&tmp.subtype); if (tmp.xtype) - FREE (&tmp.xtype); + mem_free (&tmp.xtype); } } } @@ -446,7 +446,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, if (fp) { /* recv case: we need to save the attachment to a file */ - FREE (&fname); + mem_free (&fname); if (mutt_save_attachment (fp, a, tempfile, 0, NULL) == -1) goto return_error; } diff --git a/browser.c b/browser.c index 10ecc02..d4a7157 100644 --- a/browser.c +++ b/browser.c @@ -76,14 +76,14 @@ static void destroy_state (struct browser_state *state) int c; for (c = 0; c < state->entrylen; c++) { - FREE (&((state->entry)[c].name)); - FREE (&((state->entry)[c].desc)); - FREE (&((state->entry)[c].st)); + mem_free (&((state->entry)[c].name)); + mem_free (&((state->entry)[c].desc)); + mem_free (&((state->entry)[c].st)); } #ifdef USE_IMAP - FREE (&state->folder); + mem_free (&state->folder); #endif - FREE (&state->entry); + mem_free (&state->entry); } static int browser_compare_subject (const void *a, const void *b) @@ -424,7 +424,7 @@ static void add_folder (MUTTMENU * m, struct browser_state *state, { if (state->entrylen == state->entrymax) { /* need to allocate more space */ - safe_realloc (&state->entry, + mem_realloc (&state->entry, sizeof (struct folder_file) * (state->entrymax += 256)); memset (&state->entry[state->entrylen], 0, sizeof (struct folder_file) * 256); @@ -437,7 +437,7 @@ static void add_folder (MUTTMENU * m, struct browser_state *state, (state->entry)[state->entrylen].mtime = s->st_mtime; (state->entry)[state->entrylen].size = s->st_size; - (state->entry)[state->entrylen].st = safe_malloc (sizeof (struct stat)); + (state->entry)[state->entrylen].st = mem_malloc (sizeof (struct stat)); memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat)); } @@ -459,7 +459,7 @@ static void init_state (struct browser_state *state, MUTTMENU * menu) state->entrylen = 0; state->entrymax = 256; state->entry = - (struct folder_file *) safe_calloc (state->entrymax, + (struct folder_file *) mem_calloc (state->entrymax, sizeof (struct folder_file)); #ifdef USE_IMAP state->imap_browse = 0; @@ -996,7 +996,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (menu->tagged) { *numfiles = menu->tagged; - tfiles = safe_calloc (*numfiles, sizeof (char *)); + tfiles = mem_calloc (*numfiles, sizeof (char *)); for (i = 0, j = 0; i < state.entrylen; i++) { struct folder_file ff = state.entry[i]; char full[_POSIX_PATH_MAX]; @@ -1011,7 +1011,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } else if (f[0]) { /* no tagged entries. return selected entry */ *numfiles = 1; - tfiles = safe_calloc (*numfiles, sizeof (char *)); + tfiles = mem_calloc (*numfiles, sizeof (char *)); mutt_expand_path (f, flen); tfiles[0] = str_dup (f); *files = tfiles; @@ -1091,8 +1091,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (mutt_yesorno (msg, M_NO) == M_YES) { if (!imap_delete_mailbox (Context, mx)) { /* free the mailbox from the browser */ - FREE (&((state.entry)[nentry].name)); - FREE (&((state.entry)[nentry].desc)); + mem_free (&((state.entry)[nentry].name)); + mem_free (&((state.entry)[nentry].desc)); /* and move all other entries up */ if (nentry + 1 < state.entrylen) memmove (state.entry + nentry, state.entry + nentry + 1, @@ -1107,7 +1107,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } else mutt_message _("Mailbox not deleted."); - FREE (&mx.mbox); + mem_free (&mx.mbox); } break; #endif @@ -1179,7 +1179,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, strfcpy (buf, NONULL (Mask.pattern), sizeof (buf)); if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) { - regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); + regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t)); char *s = buf; int not = 0, err; @@ -1197,13 +1197,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) { regerror (err, rx, buf, sizeof (buf)); regfree (rx); - FREE (&rx); + mem_free (&rx); mutt_error ("%s", buf); } else { str_replace (&Mask.pattern, buf); regfree (Mask.rx); - FREE (&Mask.rx); + mem_free (&Mask.rx); Mask.rx = rx; Mask.not = not; @@ -1384,7 +1384,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, folder.ff->st = NULL; folder.ff->is_new = nd->new; folder.ff->nd = nd; - FREE (&f->desc); + mem_free (&f->desc); mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); @@ -1428,7 +1428,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, case OP_SUBSCRIBE_PATTERN: case OP_UNSUBSCRIBE_PATTERN: if (option (OPTNEWS)) { - regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); + regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t)); char *s = buf; int j = menu->current; NNTP_DATA *nd; @@ -1444,14 +1444,14 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, else snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) { - FREE (&rx); + mem_free (&rx); break; } if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) { regerror (err, rx, buf, sizeof (buf)); regfree (rx); - FREE (&rx); + mem_free (&rx); mutt_error ("%s", buf); break; } @@ -1482,7 +1482,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, folder.f = NULL; folder.new = nd->new; folder.nd = nd; - FREE (&f->desc); + mem_free (&f->desc); mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); @@ -1516,7 +1516,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, nntp_clear_cacheindex (news); if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) regfree (rx); - FREE (&rx); + mem_free (&rx); } #ifdef USE_IMAP else diff --git a/buffy.c b/buffy.c index ac8ef46..b468fd1 100644 --- a/buffy.c +++ b/buffy.c @@ -169,8 +169,8 @@ void buffy_update_mailbox (BUFFY * b) /* func to free buffy for list_del() */ static void buffy_free (BUFFY** p) { - FREE(&(*p)->path); - FREE(p); + mem_free(&(*p)->path); + mem_free(p); } int buffy_lookup (const char* path) { @@ -219,7 +219,7 @@ int buffy_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data, } if (i < 0) { - tmp = safe_calloc (1, sizeof (BUFFY)); + tmp = mem_calloc (1, sizeof (BUFFY)); tmp->path = str_dup (buf); tmp->magic = 0; list_push_back (&Incoming, tmp); diff --git a/charset.c b/charset.c index 5f3a273..0b2d979 100644 --- a/charset.c +++ b/charset.c @@ -409,14 +409,14 @@ int mutt_convert_string (char **ps, const char *from, const char *to, len = str_len (s); ib = s, ibl = len + 1; obl = MB_LEN_MAX * ibl; - ob = buf = safe_malloc (obl + 1); + ob = buf = mem_malloc (obl + 1); mutt_iconv (cd, &ib, &ibl, &ob, &obl, inrepls, outrepl); iconv_close (cd); *ob = '\0'; - FREE (ps); + mem_free (ps); *ps = buf; str_adjust (ps); @@ -460,14 +460,14 @@ FGETCONV *fgetconv_open (FILE * file, const char *from, const char *to, cd = mutt_iconv_open (to, from, flags); if (cd != (iconv_t) - 1) { - fc = safe_malloc (sizeof (struct fgetconv_s)); + fc = mem_malloc (sizeof (struct fgetconv_s)); fc->p = fc->ob = fc->bufo; fc->ib = fc->bufi; fc->ibl = 0; fc->inrepls = mutt_is_utf8 (to) ? repls : repls + 1; } else - fc = safe_malloc (sizeof (struct fgetconv_not)); + fc = mem_malloc (sizeof (struct fgetconv_not)); fc->file = file; fc->cd = cd; return (FGETCONV *) fc; @@ -552,7 +552,7 @@ void fgetconv_close (FGETCONV ** _fc) if (fc->cd != (iconv_t) - 1) iconv_close (fc->cd); - FREE (_fc); + mem_free (_fc); } char *mutt_get_first_charset (const char *charset) @@ -582,11 +582,11 @@ static size_t convert_string (ICONV_CONST char *f, size_t flen, if (cd == (iconv_t) (-1)) return (size_t) (-1); obl = 4 * flen + 1; - ob = buf = safe_malloc (obl); + ob = buf = mem_malloc (obl); n = iconv (cd, &f, &flen, &ob, &obl); if (n == (size_t) (-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t) (-1)) { e = errno; - FREE (&buf); + mem_free (&buf); iconv_close (cd); errno = e; return (size_t) (-1); @@ -595,7 +595,7 @@ static size_t convert_string (ICONV_CONST char *f, size_t flen, *tlen = ob - buf; - safe_realloc (&buf, ob - buf + 1); + mem_realloc (&buf, ob - buf + 1); *t = buf; iconv_close (cd); @@ -621,12 +621,12 @@ int mutt_convert_nonmime_string (char **ps) n = c1 ? c1 - c : str_len (c); if (!n) continue; - fromcode = safe_malloc (n + 1); + fromcode = mem_malloc (n + 1); strfcpy (fromcode, c, n + 1); m = convert_string (u, ulen, fromcode, Charset, &s, &slen); - FREE (&fromcode); + mem_free (&fromcode); if (m != (size_t) (-1)) { - FREE (ps); + mem_free (ps); *ps = s; return 0; } diff --git a/color.c b/color.c index 51d2f83..8980b0b 100644 --- a/color.c +++ b/color.c @@ -96,7 +96,7 @@ static struct mapping_t Fields[] = { static COLOR_LINE *mutt_new_color_line (void) { - COLOR_LINE *p = safe_calloc (1, sizeof (COLOR_LINE)); + COLOR_LINE *p = mem_calloc (1, sizeof (COLOR_LINE)); p->fg = p->bg = -1; @@ -123,14 +123,14 @@ static void mutt_free_color_line (COLOR_LINE ** l, int free_colors) regfree (&tmp->rx); mutt_pattern_free (&tmp->color_pattern); - FREE (&tmp->pattern); - FREE (l); + mem_free (&tmp->pattern); + mem_free (l); } void ci_start_color (void) { memset (ColorDefs, A_NORMAL, sizeof (int) * MT_COLOR_MAX); - ColorQuote = (int *) safe_malloc (COLOR_QUOTE_INIT * sizeof (int)); + ColorQuote = (int *) mem_malloc (COLOR_QUOTE_INIT * sizeof (int)); memset (ColorQuote, A_NORMAL, sizeof (int) * COLOR_QUOTE_INIT); ColorQuoteSize = COLOR_QUOTE_INIT; ColorQuoteUsed = 0; @@ -223,7 +223,7 @@ int mutt_alloc_color (int fg, int bg) i++; } - p = (COLOR_LIST *) safe_malloc (sizeof (COLOR_LIST)); + p = (COLOR_LIST *) mem_malloc (sizeof (COLOR_LIST)); p->next = ColorList; ColorList = p; @@ -267,14 +267,14 @@ void mutt_free_color (int fg, int bg) if (p == ColorList) { ColorList = ColorList->next; - FREE (&p); + mem_free (&p); return; } q = ColorList; while (q) { if (q->next == p) { q->next = p->next; - FREE (&p); + mem_free (&p); return; } q = q->next; @@ -698,7 +698,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, } else if (object == MT_COLOR_QUOTED) { if (q_level >= ColorQuoteSize) { - safe_realloc (&ColorQuote, (ColorQuoteSize += 2) * sizeof (int)); + mem_realloc (&ColorQuote, (ColorQuoteSize += 2) * sizeof (int)); ColorQuote[ColorQuoteSize - 2] = ColorDefs[MT_COLOR_QUOTED]; ColorQuote[ColorQuoteSize - 1] = ColorDefs[MT_COLOR_QUOTED]; } diff --git a/commands.c b/commands.c index 9475e38..20ed011 100644 --- a/commands.c +++ b/commands.c @@ -262,7 +262,7 @@ void ci_bounce_message (HEADER * h, int *redraw) if (mutt_addrlist_to_idna (adr, &err) < 0) { mutt_error (_("Bad IDN: '%s'"), err); - FREE (&err); + mem_free (&err); rfc822_free_address (&adr); return; } @@ -570,7 +570,7 @@ void mutt_enter_command (void) err.dsize = sizeof (errbuf); memset (&token, 0, sizeof (token)); r = mutt_parse_rc_line (buffer, &token, &err); - FREE (&token.data); + mem_free (&token.data); if (errbuf[0]) { /* since errbuf could potentially contain printf() sequences in it, we must call mutt_error() in this fashion so that vsprintf() @@ -980,7 +980,7 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp) /* clean up previous junk */ mutt_free_parameter (&b->parameter); - FREE (&b->subtype); + mem_free (&b->subtype); mutt_parse_content_type (buf, b); diff --git a/compose.c b/compose.c index f2afd32..0530751 100644 --- a/compose.c +++ b/compose.c @@ -337,7 +337,7 @@ static int edit_address_list (int line, ADDRESS ** addr) if (mutt_addrlist_to_idna (*addr, &err) != 0) { mutt_error (_("Warning: '%s' is a bad IDN."), err); mutt_refresh (); - FREE (&err); + mem_free (&err); } /* redraw the expanded list so the user can see the result */ @@ -373,8 +373,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)); - FREE (&idx[x]->tree); - FREE (&idx[x]); + mem_free (&idx[x]->tree); + mem_free (&idx[x]); for (; x < *idxlen - 1; x++) idx[x] = idx[x + 1]; menu->max = --(*idxlen); @@ -617,7 +617,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ buf[0] = 0; if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0]) { - FREE (&msg->env->newsgroups); + mem_free (&msg->env->newsgroups); str_skip_trailws (buf); msg->env->newsgroups = str_dup (str_skip_initws (buf)); move (HDR_TO, HDR_XOFFSET); @@ -635,7 +635,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ strfcpy (buf, msg->env->followup_to, sizeof (buf)); if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) { - FREE (&msg->env->followup_to); + mem_free (&msg->env->followup_to); str_skip_trailws (buf); msg->env->followup_to = str_dup (str_skip_initws (buf)); move (HDR_CC, HDR_XOFFSET); @@ -653,7 +653,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ strfcpy (buf, msg->env->x_comment_to, sizeof (buf)); if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) { - FREE (&msg->env->x_comment_to); + mem_free (&msg->env->x_comment_to); msg->env->x_comment_to = str_dup (buf); move (HDR_BCC, HDR_XOFFSET); clrtoeol (); @@ -714,7 +714,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ fcc, fcclen); if (mutt_env_to_idna (msg->env, &tag, &err)) { mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err); - FREE (&err); + mem_free (&err); } } else { @@ -729,7 +729,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ /* attachments may have been added */ if (idxlen && idx[idxlen - 1]->content->next) { for (i = 0; i < idxlen; i++) - FREE (&idx[i]); + mem_free (&idx[i]); idxlen = 0; idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, @@ -748,18 +748,18 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ if (!(WithCrypto & APPLICATION_PGP)) break; if (idxlen == idxmax) { - safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); + mem_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); menu->data = idx; } - idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); + idx[idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR)); if ((idx[idxlen]->content = crypt_pgp_make_key_attachment (NULL)) != NULL) { update_idx (menu, idx, idxlen++); menu->redraw |= REDRAW_INDEX; } else - FREE (&idx[idxlen]); + mem_free (&idx[idxlen]); menu->redraw |= REDRAW_STATUS; @@ -788,7 +788,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ break; if (idxlen + numfiles >= idxmax) { - safe_realloc (&idx, + mem_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles)); menu->data = idx; } @@ -800,7 +800,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ for (i = 0; i < numfiles; i++) { char *att = files[i]; - idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); + idx[idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR)); idx[idxlen]->unowned = 1; idx[idxlen]->content = mutt_make_file_attach (att); if (idx[idxlen]->content != NULL) @@ -808,11 +808,11 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ else { error = 1; mutt_error (_("Unable to attach %s!"), att); - FREE (&idx[idxlen]); + mem_free (&idx[idxlen]); } } - FREE (&files); + mem_free (&files); if (!error) mutt_clear_error (); @@ -888,7 +888,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ if (!ctx->msgcount) { mx_close_mailbox (ctx, NULL); - FREE (&ctx); + mem_free (&ctx); mutt_error _("No messages in that folder."); break; @@ -916,7 +916,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ } if (idxlen + Context->tagged >= idxmax) { - safe_realloc (&idx, + mem_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + Context->tagged)); menu->data = idx; @@ -925,14 +925,14 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ for (i = 0; i < Context->msgcount; i++) { h = Context->hdrs[i]; if (h->tagged) { - idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); + idx[idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR)); idx[idxlen]->content = mutt_make_message_attach (Context, h, 1); if (idx[idxlen]->content != NULL) update_idx (menu, idx, idxlen++); else { mutt_error _("Unable to attach!"); - FREE (&idx[idxlen]); + mem_free (&idx[idxlen]); } } } @@ -942,7 +942,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ mx_close_mailbox (Context, NULL); else mx_fastclose_mailbox (Context); - FREE (&Context); + mem_free (&Context); /* go back to the folder we started from */ Context = this; @@ -1190,15 +1190,15 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ continue; } if (idxlen == idxmax) { - safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); + mem_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); menu->data = idx; } - idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); + idx[idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR)); /* Touch the file */ if (!(fp = safe_fopen (fname, "w"))) { mutt_error (_("Can't create file %s"), fname); - FREE (&idx[idxlen]); + mem_free (&idx[idxlen]); continue; } fclose (fp); @@ -1284,10 +1284,10 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ if (idx[idxlen]->unowned) idx[idxlen]->content->unlink = 0; mutt_free_body (&idx[idxlen]->content); - FREE (&idx[idxlen]->tree); - FREE (&idx[idxlen]); + mem_free (&idx[idxlen]->tree); + mem_free (&idx[idxlen]); } - FREE (&idx); + mem_free (&idx); idxlen = 0; idxmax = 0; r = -1; @@ -1418,13 +1418,13 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ msg->content = idx[0]->content; for (i = 0; i < idxlen; i++) { idx[i]->content->aptr = NULL; - FREE (&idx[i]); + mem_free (&idx[i]); } } else msg->content = NULL; - FREE (&idx); + mem_free (&idx); return (r); } diff --git a/compress.c b/compress.c index a483b9e..e179b7d 100644 --- a/compress.c +++ b/compress.c @@ -113,7 +113,7 @@ static COMPRESS_INFO *set_compress_info (CONTEXT * ctx) COMPRESS_INFO *ci; /* Now lets uncompress this thing */ - ci = safe_malloc (sizeof (COMPRESS_INFO)); + ci = mem_malloc (sizeof (COMPRESS_INFO)); ctx->compressinfo = (void *) ci; ci->append = find_compress_hook (M_APPENDHOOK, ctx->path); ci->open = find_compress_hook (M_OPENHOOK, ctx->path); @@ -130,7 +130,7 @@ static void set_path (CONTEXT * ctx) /* Uncompress to /tmp */ mutt_mktemp (tmppath); - ctx->path = safe_malloc (str_len (tmppath) + 1); + ctx->path = mem_malloc (str_len (tmppath) + 1); strcpy (ctx->path, tmppath); } @@ -197,8 +197,8 @@ int mutt_check_mailbox_compressed (CONTEXT * ctx) COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; if (ci->size != get_size (ctx->realpath)) { - FREE (&ctx->compressinfo); - FREE (&ctx->realpath); + mem_free (&ctx->compressinfo); + mem_free (&ctx->realpath); mutt_error _("Mailbox was corrupted!"); return (-1); @@ -216,7 +216,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) if (!ci->open) { ctx->magic = 0; - FREE (ctx->compressinfo); + mem_free (ctx->compressinfo); return (-1); } if (!ci->close || access (ctx->path, W_OK) != 0) @@ -235,7 +235,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) if ((fp = fopen (ctx->realpath, "r")) == NULL) { mutt_perror (ctx->realpath); - FREE (&cmd); + mem_free (&cmd); return (-1); } mutt_block_signals (); @@ -244,7 +244,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) mutt_unblock_signals (); mutt_error _("Unable to lock mailbox!"); - FREE (&cmd); + mem_free (&cmd); return (-1); } @@ -260,11 +260,11 @@ int mutt_open_read_compressed (CONTEXT * ctx) if (rc) { mutt_any_key_to_continue (NULL); ctx->magic = 0; - FREE (ctx->compressinfo); + mem_free (ctx->compressinfo); mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd); } - FREE (&cmd); + mem_free (&cmd); if (rc) return (-1); @@ -278,7 +278,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) void restore_path (CONTEXT * ctx) { - FREE (&ctx->path); + mem_free (&ctx->path); ctx->path = ctx->realpath; } @@ -299,7 +299,7 @@ int mutt_open_append_compressed (CONTEXT * ctx) return (mutt_open_read_compressed (ctx)); ctx->magic = 0; - FREE (&ctx->compressinfo); + mem_free (&ctx->compressinfo); return (-1); } @@ -332,7 +332,7 @@ void mutt_fast_close_compressed (CONTEXT * ctx) remove_file (ctx); restore_path (ctx); - FREE (&ctx->compressinfo); + mem_free (&ctx->compressinfo); } } @@ -353,7 +353,7 @@ int mutt_sync_compressed (CONTEXT * ctx) if ((fp = fopen (ctx->realpath, "a")) == NULL) { mutt_perror (ctx->realpath); - FREE (&cmd); + mem_free (&cmd); return (-1); } mutt_block_signals (); @@ -364,7 +364,7 @@ int mutt_sync_compressed (CONTEXT * ctx) store_size (ctx); - FREE (&cmd); + mem_free (&cmd); return (-1); } @@ -386,7 +386,7 @@ int mutt_sync_compressed (CONTEXT * ctx) mutt_unblock_signals (); fclose (fp); - FREE (&cmd); + mem_free (&cmd); store_size (ctx); @@ -428,7 +428,7 @@ int mutt_slow_close_compressed (CONTEXT * ctx) if ((fp = fopen (ctx->realpath, "a")) == NULL) { mutt_perror (ctx->realpath); - FREE (&cmd); + mem_free (&cmd); return (-1); } mutt_block_signals (); @@ -437,7 +437,7 @@ int mutt_slow_close_compressed (CONTEXT * ctx) mutt_unblock_signals (); mutt_error _("Unable to lock mailbox!"); - FREE (&cmd); + mem_free (&cmd); return (-1); } @@ -458,7 +458,7 @@ int mutt_slow_close_compressed (CONTEXT * ctx) mutt_error (_ (" %s: Error compressing mailbox! Uncompressed one kept!\n"), ctx->path); - FREE (&cmd); + mem_free (&cmd); mbox_unlock_compressed (ctx, fp); mutt_unblock_signals (); fclose (fp); @@ -470,14 +470,14 @@ int mutt_slow_close_compressed (CONTEXT * ctx) fclose (fp); remove_file (ctx); restore_path (ctx); - FREE (&cmd); - FREE (&ctx->compressinfo); + mem_free (&cmd); + mem_free (&ctx->compressinfo); return (0); } mx_t* compress_reg_mx (void) { - mx_t* fmt = safe_calloc (1, sizeof (mx_t)); + mx_t* fmt = mem_calloc (1, sizeof (mx_t)); fmt->type = M_COMPRESSED; fmt->local = 1; fmt->mx_is_magic = mbox_is_magic; diff --git a/copy.c b/copy.c index cbca670..567d0e4 100644 --- a/copy.c +++ b/copy.c @@ -124,7 +124,7 @@ mutt_copy_hdr (FILE * in, FILE * out, long off_start, long off_end, int flags, debug_print (1, ("WEED is %s\n", (flags & CH_WEED) ? "Set" : "Not")); - headers = safe_calloc (hdr_count, sizeof (char *)); + headers = mem_calloc (hdr_count, sizeof (char *)); /* Read all the headers into the array */ while (ftell (in) < off_end) { @@ -146,10 +146,10 @@ mutt_copy_hdr (FILE * in, FILE * out, long off_start, long off_end, int flags, if (!headers[x]) headers[x] = this_one; else { - safe_realloc (&headers[x], str_len (headers[x]) + + mem_realloc (&headers[x], str_len (headers[x]) + str_len (this_one) + sizeof (char)); strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */ - FREE (&this_one); + mem_free (&this_one); } this_one = NULL; @@ -213,7 +213,7 @@ mutt_copy_hdr (FILE * in, FILE * out, long off_start, long off_end, int flags, if (!this_one) this_one = str_dup (buf); else { - safe_realloc (&this_one, + mem_realloc (&this_one, str_len (this_one) + str_len (buf) + sizeof (char)); strcat (this_one, buf); /* __STRCAT_CHECKED__ */ @@ -231,10 +231,10 @@ mutt_copy_hdr (FILE * in, FILE * out, long off_start, long off_end, int flags, if (!headers[x]) headers[x] = this_one; else { - safe_realloc (&headers[x], str_len (headers[x]) + + mem_realloc (&headers[x], str_len (headers[x]) + str_len (this_one) + sizeof (char)); strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */ - FREE (&this_one); + mem_free (&this_one); } this_one = NULL; @@ -287,8 +287,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++) - FREE (&headers[x]); - FREE (&headers); + mem_free (&headers[x]); + mem_free (&headers); if (error) return (-1); @@ -374,7 +374,7 @@ mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags, /* Mutt stores references in reverse order, thus we create * a reordered refs list that we can put in the headers */ for (; listp; listp = listp->next, refs = t) { - t = (LIST *) safe_malloc (sizeof (LIST)); + t = (LIST *) mem_malloc (sizeof (LIST)); t->data = listp->data; t->next = refs; } @@ -385,7 +385,7 @@ mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags, /* clearing refs from memory */ for (t = refs; refs; refs = t->next, t = refs) - FREE (&refs); + mem_free (&refs); if (fputc ('\n', out) == EOF) return (-1); @@ -808,7 +808,7 @@ static void format_address_header (char **h, ADDRESS * a) buflen = linelen + 3; - safe_realloc (h, buflen); + mem_realloc (h, buflen); for (count = 0; a; a = a->next, count++) { ADDRESS *tmp = a->next; @@ -836,7 +836,7 @@ static void format_address_header (char **h, ADDRESS * a) } buflen += l + str_len (cbuf) + str_len (c2buf); - safe_realloc (h, buflen); + mem_realloc (h, buflen); strcat (*h, cbuf); /* __STRCAT_CHECKED__ */ strcat (*h, buf); /* __STRCAT_CHECKED__ */ strcat (*h, c2buf); /* __STRCAT_CHECKED__ */ @@ -919,7 +919,7 @@ static int address_header_decode (char **h) mutt_addrlist_to_local (a); rfc2047_decode_adrlist (a); - *h = safe_calloc (1, l + 2); + *h = mem_calloc (1, l + 2); strfcpy (*h, s, l + 1); @@ -927,6 +927,6 @@ static int address_header_decode (char **h) rfc822_free_address (&a); - FREE (&s); + mem_free (&s); return 1; } diff --git a/crypt-gpgme.c b/crypt-gpgme.c index f22ca2d..ed84713 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -128,12 +128,12 @@ static void print_utf8 (FILE * fp, const char *buf, size_t len) { char *tstr; - tstr = safe_malloc (len + 1); + tstr = mem_malloc (len + 1); memcpy (tstr, buf, len); tstr[len] = 0; mutt_convert_string (&tstr, "utf-8", Charset, M_ICONV_HOOK_FROM); fputs (tstr, fp); - FREE (&tstr); + mem_free (&tstr); } @@ -212,7 +212,7 @@ static crypt_key_t *crypt_copy_key (crypt_key_t * key) { crypt_key_t *k; - k = safe_calloc (1, sizeof *k); + k = mem_calloc (1, sizeof *k); k->kobj = key->kobj; gpgme_key_ref (key->kobj); k->idx = key->idx; @@ -229,7 +229,7 @@ static void crypt_free_key (crypt_key_t ** keylist) while (*keylist) { crypt_key_t *k = (*keylist)->next; - FREE (&k); + mem_free (&k); *keylist = k; } } @@ -550,13 +550,13 @@ static gpgme_key_t *create_recipient_set (const char *keylist, err = gpgme_get_key (context, buf, &key, 0); if (!err) { - safe_realloc (&rset, sizeof (*rset) * (rset_n + 1)); + mem_realloc (&rset, sizeof (*rset) * (rset_n + 1)); rset[rset_n++] = key; } else { mutt_error (_("error adding recipient `%s': %s\n"), buf, gpgme_strerror (err)); - FREE (&rset); + mem_free (&rset); return NULL; } } @@ -564,7 +564,7 @@ static gpgme_key_t *create_recipient_set (const char *keylist, } /* NULL terminate. */ - safe_realloc (&rset, sizeof (*rset) * (rset_n + 1)); + mem_realloc (&rset, sizeof (*rset) * (rset_n + 1)); rset[rset_n++] = NULL; if (context) @@ -832,13 +832,13 @@ BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign) convert_to_7bit (a); plaintext = body_to_data_object (a, 0); if (!plaintext) { - FREE (&rset); + mem_free (&rset); return NULL; } outfile = encrypt_gpgme_object (plaintext, rset, 0, sign); gpgme_data_release (plaintext); - FREE (&rset); + mem_free (&rset); if (!outfile) return NULL; @@ -890,13 +890,13 @@ BODY *smime_gpgme_build_smime_entity (BODY * a, char *keylist) plaintext = body_to_data_object (a, 0); if (!plaintext) { - FREE (&rset); + mem_free (&rset); return NULL; } outfile = encrypt_gpgme_object (plaintext, rset, 1, 0); gpgme_data_release (plaintext); - FREE (&rset); + mem_free (&rset); if (!outfile) return NULL; @@ -1030,7 +1030,7 @@ static void show_fingerprint (gpgme_key_t key, STATE * state) return; is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP); - buf = safe_malloc (str_len (prefix) + str_len (s) * 4 + 2); + buf = mem_malloc (str_len (prefix) + str_len (s) * 4 + 2); strcpy (buf, prefix); /* __STRCPY_CHECKED__ */ p = buf + str_len (buf); if (is_pgp && str_len (s) == 40) { /* PGP v4 style formatted. */ @@ -1060,7 +1060,7 @@ static void show_fingerprint (gpgme_key_t key, STATE * state) *p++ = '\n'; *p = 0; state_attach_puts (buf, state); - FREE (&buf); + mem_free (&buf); } /* Show the valididy of a key used for one signature. */ @@ -1725,7 +1725,7 @@ static void copy_clearsigned (gpgme_data_t data, STATE * s, char *charset) if (!fname) return; unlink (fname); - FREE (&fname); + mem_free (&fname); fc = fgetconv_open (fp, charset, Charset, M_ICONV_HOOK_FROM); @@ -1917,7 +1917,7 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) } else { unlink (tmpfname); - FREE (&tmpfname); + mem_free (&tmpfname); } } gpgme_release (ctx); @@ -2538,7 +2538,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, n = s - string; if (!n) return NULL; /* empty key */ - array->key = safe_malloc (n + 1); + array->key = mem_malloc (n + 1); p = (unsigned char *) array->key; memcpy (p, string, n); /* fixme: trim trailing spaces */ p[n] = 0; @@ -2552,7 +2552,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, if (!n || (n & 1)) return NULL; /* empty or odd number of digits */ n /= 2; - p = safe_malloc (n + 1); + p = mem_malloc (n + 1); array->value = (char *) p; for (s1 = string; n; s1 += 2, n--) *p++ = xtoi_2 (s1); @@ -2582,7 +2582,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, n++; } - p = safe_malloc (n + 1); + p = mem_malloc (n + 1); array->value = (char *) p; for (s = string; n; s++, n--) { if (*s == '\\') { @@ -2613,7 +2613,7 @@ static struct dn_array_s *parse_dn (const unsigned char *string) int i; arraysize = 7; /* C,ST,L,O,OU,CN,email */ - array = safe_malloc ((arraysize + 1) * sizeof *array); + array = mem_malloc ((arraysize + 1) * sizeof *array); arrayidx = 0; while (*string) { while (*string == ' ') @@ -2624,12 +2624,12 @@ static struct dn_array_s *parse_dn (const unsigned char *string) struct dn_array_s *a2; arraysize += 5; - a2 = safe_malloc ((arraysize + 1) * sizeof *array); + a2 = mem_malloc ((arraysize + 1) * sizeof *array); for (i = 0; i < arrayidx; i++) { a2[i].key = array[i].key; a2[i].value = array[i].value; } - FREE (&array); + mem_free (&array); array = a2; } array[arrayidx].key = NULL; @@ -2651,10 +2651,10 @@ static struct dn_array_s *parse_dn (const unsigned char *string) failure: for (i = 0; i < arrayidx; i++) { - FREE (&array[i].key); - FREE (&array[i].value); + mem_free (&array[i].key); + mem_free (&array[i].value); } - FREE (&array); + mem_free (&array); return NULL; } @@ -2685,10 +2685,10 @@ static void parse_and_print_user_id (FILE * fp, const char *userid) else { print_dn_parts (fp, dn); for (i = 0; dn[i].key; i++) { - FREE (&dn[i].key); - FREE (&dn[i].value); + mem_free (&dn[i].key); + mem_free (&dn[i].value); } - FREE (&dn); + mem_free (&dn); } } } @@ -3035,7 +3035,7 @@ static char *list_to_pattern (LIST * list) n++; /* delimiter or end of string */ } n++; /* make sure to allocate at least one byte */ - pattern = p = safe_calloc (1, n); + pattern = p = mem_calloc (1, n); for (l = list; l; l = l->next) { s = l->data; if (*s) { @@ -3083,7 +3083,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, err = gpgme_new (&ctx); if (err) { mutt_error (_("gpgme_new failed: %s"), gpgme_strerror (err)); - FREE (&pattern); + mem_free (&pattern); return NULL; } @@ -3106,7 +3106,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, if (!n) goto no_pgphints; - patarr = safe_calloc (n + 1, sizeof *patarr); + patarr = mem_calloc (n + 1, sizeof *patarr); for (l = hints, n = 0; l; l = l->next) { if (l->data && *l->data) patarr[n++] = str_dup (l->data); @@ -3114,12 +3114,12 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, patarr[n] = NULL; err = gpgme_op_keylist_ext_start (ctx, (const char **) patarr, secret, 0); for (n = 0; patarr[n]; n++) - FREE (&patarr[n]); - FREE (&patarr); + mem_free (&patarr[n]); + mem_free (&patarr); if (err) { mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err)); gpgme_release (ctx); - FREE (&pattern); + mem_free (&pattern); return NULL; } @@ -3152,7 +3152,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, #endif /* DISABLED code */ for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) { - k = safe_calloc (1, sizeof *k); + k = mem_calloc (1, sizeof *k); k->kobj = key; k->idx = idx; k->uid = uid->uid; @@ -3175,7 +3175,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, if (err) { mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err)); gpgme_release (ctx); - FREE (&pattern); + mem_free (&pattern); return NULL; } @@ -3188,7 +3188,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, flags |= KEYFLAG_CANSIGN; for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) { - k = safe_calloc (1, sizeof *k); + k = mem_calloc (1, sizeof *k); k->kobj = key; k->idx = idx; k->uid = uid->uid; @@ -3203,7 +3203,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, } gpgme_release (ctx); - FREE (&pattern); + mem_free (&pattern); return db; } @@ -3223,7 +3223,7 @@ static LIST *crypt_add_string_to_hints (LIST * hints, const char *str) hints = mutt_add_list (hints, t); } - FREE (&scratch); + mem_free (&scratch); return hints; } @@ -3257,7 +3257,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t * keys, if (i == keymax) { keymax += 20; - safe_realloc (&key_table, sizeof (crypt_key_t *) * keymax); + mem_realloc (&key_table, sizeof (crypt_key_t *) * keymax); } key_table[i++] = k; @@ -3415,7 +3415,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t * keys, } mutt_menuDestroy (&menu); - FREE (&key_table); + mem_free (&key_table); set_option (OPTNEEDREDRAW); @@ -3636,7 +3636,7 @@ static crypt_key_t *crypt_ask_for_key (char *tag, if (l) str_replace (&l->dflt, resp); else { - l = safe_malloc (sizeof (struct crypt_cache)); + l = mem_malloc (sizeof (struct crypt_cache)); l->next = id_defaults; id_defaults = l; l->what = str_dup (whatfor); @@ -3727,7 +3727,7 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc, } } else if (r == -1) { - FREE (&keylist); + mem_free (&keylist); rfc822_free_address (&tmp); rfc822_free_address (&addr); return NULL; @@ -3746,7 +3746,7 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc, app, #endif &forced_valid)) == NULL) { - FREE (&keylist); + mem_free (&keylist); rfc822_free_address (&tmp); rfc822_free_address (&addr); return NULL; @@ -3766,7 +3766,7 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc, #endif keylist_size += str_len (s) + 4 + 1; - safe_realloc (&keylist, keylist_size); + mem_realloc (&keylist, keylist_size); sprintf (keylist + keylist_used, "%s0x%s%s", /* __SPRINTF_CHECKED__ */ keylist_used ? " " : "", s, forced_valid ? "!" : ""); } diff --git a/crypt-mod.c b/crypt-mod.c index c328116..9200ef9 100644 --- a/crypt-mod.c +++ b/crypt-mod.c @@ -27,7 +27,7 @@ static crypt_module_t modules; /* Register a new crypto module. */ void crypto_module_register (crypt_module_specs_t specs) { - crypt_module_t module_new = safe_malloc (sizeof (*module_new)); + crypt_module_t module_new = mem_malloc (sizeof (*module_new)); module_new->specs = specs; module_new->next = modules; diff --git a/crypt.c b/crypt.c index 2f20bc1..9d175d9 100644 --- a/crypt.c +++ b/crypt.c @@ -705,7 +705,7 @@ static void crypt_fetch_signatures (BODY *** signatures, BODY * a, int *n) crypt_fetch_signatures (signatures, a->parts, n); else { if ((*n % 5) == 0) - safe_realloc (signatures, (*n + 6) * sizeof (BODY **)); + mem_realloc (signatures, (*n + 6) * sizeof (BODY **)); (*signatures)[(*n)++] = a; } @@ -825,7 +825,7 @@ void mutt_signed_handler (BODY * a, STATE * s) state_attach_puts (_("[-- The following data is signed --]\n\n"), s); - FREE (&signatures); + mem_free (&signatures); } else state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), diff --git a/curs_lib.c b/curs_lib.c index 6482b62..b9c4557 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -213,12 +213,12 @@ int mutt_yesorno (const char *msg, int def) * ensure there is enough room for the answer and truncate the question * to fit. */ - answer_string = safe_malloc (COLS + 1); + answer_string = mem_malloc (COLS + 1); snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no, def == M_YES ? no : yes); answer_string_len = str_len (answer_string); printw ("%.*s%s", COLS - answer_string_len, msg, answer_string); - FREE (&answer_string); + mem_free (&answer_string); FOREVER { mutt_refresh (); @@ -446,7 +446,7 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, *redraw = REDRAW_FULL; } else { - char *pc = safe_malloc (str_len (prompt) + 3); + char *pc = mem_malloc (str_len (prompt) + 3); sprintf (pc, "%s: ", prompt); /* __SPRINTF_CHECKED__ */ mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0); @@ -456,7 +456,7 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, != 0) buf[0] = 0; MAYBE_REDRAW (*redraw); - FREE (&pc); + mem_free (&pc); } return 0; @@ -470,7 +470,7 @@ void mutt_ungetch (int ch, int op) tmp.op = op; if (UngetCount >= UngetBufLen) - safe_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t)); + mem_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t)); KeyEvent[UngetCount++] = tmp; } diff --git a/curs_main.c b/curs_main.c index 3fd4641..cb39d66 100644 --- a/curs_main.c +++ b/curs_main.c @@ -288,7 +288,7 @@ static void update_index (MUTTMENU * menu, CONTEXT * ctx, int check, /* save the list of new messages */ if (oldcount && check != M_REOPENED && ((Sort & SORT_MASK) == SORT_THREADS)) { save_new = - (HEADER **) safe_malloc (sizeof (HEADER *) * + (HEADER **) mem_malloc (sizeof (HEADER *) * (Context->msgcount - oldcount)); for (j = oldcount; j < Context->msgcount; j++) save_new[j - oldcount] = Context->hdrs[j]; @@ -321,7 +321,7 @@ static void update_index (MUTTMENU * menu, CONTEXT * ctx, int check, mutt_uncollapse_thread (Context, h); } } - FREE (&save_new); + mem_free (&save_new); mutt_set_virtual (Context); } } @@ -474,7 +474,7 @@ int mutt_index_menu (void) if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0) { if (!Context->path) { /* fatal error occurred */ - FREE (&Context); + mem_free (&Context); menu->redraw = REDRAW_FULL; } set_option (OPTSEARCHINVALID); @@ -956,7 +956,7 @@ int mutt_index_menu (void) snprintf (buf, sizeof (buf), "~A"); unset_option (OPTHIDEREAD); } - FREE (&Context->pattern); + mem_free (&Context->pattern); Context->pattern = str_dup (buf); } if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) || @@ -1142,7 +1142,7 @@ int mutt_index_menu (void) /* check for a fatal error, or all messages deleted */ if (!Context->path) - FREE (&Context); + mem_free (&Context); /* if we were in the pager, redisplay the message */ if (menu->menu == MENU_PAGER) { @@ -1241,7 +1241,7 @@ int mutt_index_menu (void) menu->redraw = REDRAW_INDEX | REDRAW_STATUS; break; } - FREE (&Context); + mem_free (&Context); } mutt_sleep (0); @@ -1324,7 +1324,7 @@ int mutt_index_menu (void) { if (Context) { mx_fastclose_mailbox (Context); - FREE (&Context); + mem_free (&Context); } done = 1; } diff --git a/edit.c b/edit.c index c11cad8..88eeca3 100644 --- a/edit.c +++ b/edit.c @@ -74,11 +74,11 @@ static char **be_snarf_data (FILE * f, char **buf, int *bufmax, int *buflen, break; bytes -= str_len (p); if (*bufmax == *buflen) - safe_realloc (&buf, sizeof (char *) * (*bufmax += 25)); + mem_realloc (&buf, sizeof (char *) * (*bufmax += 25)); buf[(*buflen)++] = str_dup (tmp); } if (buf && *bufmax == *buflen) { /* Do not smash memory past buf */ - safe_realloc (&buf, sizeof (char *) * (++*bufmax)); + mem_realloc (&buf, sizeof (char *) * (++*bufmax)); } if (buf) buf[*buflen] = NULL; @@ -130,9 +130,9 @@ static int be_barf_file (const char *path, char **buf, int buflen) static void be_free_memory (char **buf, int buflen) { while (buflen-- > 0) - FREE (&buf[buflen]); + mem_free (&buf[buflen]); if (buf) - FREE (&buf); + mem_free (&buf); } static char **be_include_messages (char *msg, char **buf, int *bufmax, @@ -154,7 +154,7 @@ static char **be_include_messages (char *msg, char **buf, int *bufmax, } if (*bufmax == *buflen) - safe_realloc (&buf, sizeof (char *) * (*bufmax += 25)); + mem_realloc (&buf, sizeof (char *) * (*bufmax += 25)); buf[(*buflen)++] = str_dup (tmp); bytes = Context->hdrs[n]->content->length; @@ -168,7 +168,7 @@ static char **be_include_messages (char *msg, char **buf, int *bufmax, pfx); if (*bufmax == *buflen) - safe_realloc (&buf, sizeof (char *) * (*bufmax += 25)); + mem_realloc (&buf, sizeof (char *) * (*bufmax += 25)); buf[(*buflen)++] = str_dup ("\n"); } else @@ -390,7 +390,7 @@ int mutt_builtin_editor (const char *path, HEADER * msg, HEADER * cur) buflen--; strfcpy (tmp, buf[buflen], sizeof (tmp)); tmp[str_len (tmp) - 1] = 0; - FREE (&buf[buflen]); + mem_free (&buf[buflen]); buf[buflen] = NULL; continue; } @@ -438,7 +438,7 @@ int mutt_builtin_editor (const char *path, HEADER * msg, HEADER * cur) else { str_cat (tmp, sizeof (tmp), "\n"); if (buflen == bufmax) - safe_realloc (&buf, sizeof (char *) * (bufmax += 25)); + mem_realloc (&buf, sizeof (char *) * (bufmax += 25)); buf[buflen++] = str_dup (tmp[1] == '~' ? tmp + 1 : tmp); } diff --git a/enter.c b/enter.c index 8dac226..2f7a0f3 100644 --- a/enter.c +++ b/enter.c @@ -132,7 +132,7 @@ size_t my_mbstowcs (wchar_t ** pwbuf, size_t * pwbuflen, size_t i, char *buf) k != (size_t) (-1) && k != (size_t) (-2); buf += k) { if (i >= wbuflen) { wbuflen = i + 20; - safe_realloc (&wbuf, wbuflen * sizeof (*wbuf)); + mem_realloc (&wbuf, wbuflen * sizeof (*wbuf)); } wbuf[i++] = wc; } @@ -148,7 +148,7 @@ static void replace_part (ENTER_STATE * state, size_t from, char *buf) { /* Save the suffix */ size_t savelen = state->lastchar - state->curpos; - wchar_t *savebuf = safe_calloc (savelen, sizeof (wchar_t)); + wchar_t *savebuf = mem_calloc (savelen, sizeof (wchar_t)); memcpy (savebuf, state->wbuf + state->curpos, savelen * sizeof (wchar_t)); @@ -158,14 +158,14 @@ static void replace_part (ENTER_STATE * state, size_t from, char *buf) /* Make space for suffix */ if (state->curpos + savelen > state->wbuflen) { state->wbuflen = state->curpos + savelen; - safe_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t)); + mem_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t)); } /* Restore suffix */ memcpy (state->wbuf + state->curpos, savebuf, savelen * sizeof (wchar_t)); state->lastchar = state->curpos + savelen; - FREE (&savebuf); + mem_free (&savebuf); } /* @@ -468,7 +468,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x, } if (!mutt_complete (buf, buflen)) { templen = state->lastchar - i; - safe_realloc (&tempbuf, templen * sizeof (wchar_t)); + mem_realloc (&tempbuf, templen * sizeof (wchar_t)); } else BEEP (); @@ -536,7 +536,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x, if (!mutt_complete (buf, buflen)) { templen = state->lastchar; - safe_realloc (&tempbuf, templen * sizeof (wchar_t)); + mem_realloc (&tempbuf, templen * sizeof (wchar_t)); memcpy (tempbuf, state->wbuf, templen * sizeof (wchar_t)); } else @@ -635,7 +635,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x, char **tfiles; *numfiles = 1; - tfiles = safe_calloc (*numfiles, sizeof (char *)); + tfiles = mem_calloc (*numfiles, sizeof (char *)); mutt_expand_path (buf, buflen); tfiles[0] = str_dup (buf); *files = tfiles; @@ -646,7 +646,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x, else if (wc && (wc < ' ' || IsWPrint (wc))) { /* why? */ if (state->lastchar >= state->wbuflen) { state->wbuflen = state->lastchar + 20; - safe_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t)); + mem_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t)); } memmove (state->wbuf + state->curpos + 1, state->wbuf + state->curpos, (state->lastchar - state->curpos) * sizeof (wchar_t)); @@ -662,7 +662,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x, bye: - FREE (&tempbuf); + mem_free (&tempbuf); return rv; } @@ -671,8 +671,8 @@ void mutt_free_enter_state (ENTER_STATE ** esp) if (!esp) return; - FREE (&(*esp)->wbuf); - FREE (esp); + mem_free (&(*esp)->wbuf); + mem_free (esp); } /* diff --git a/gnupgparse.c b/gnupgparse.c index cf58ab6..c29ab84 100644 --- a/gnupgparse.c +++ b/gnupgparse.c @@ -88,7 +88,7 @@ static void fix_uid (char *uid) char *ob; size_t ibl, obl; - buf = safe_malloc (n + 1); + buf = mem_malloc (n + 1); ib = uid, ibl = d - uid + 1, ob = buf, obl = n; iconv (cd, &ib, &ibl, &ob, &obl); if (!ibl) { @@ -99,7 +99,7 @@ static void fix_uid (char *uid) else if (ob - buf == n && (buf[n] = 0, str_len (buf) < n)) memcpy (uid, buf, n); } - FREE (&buf); + mem_free (&buf); iconv_close (cd); } } @@ -142,7 +142,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k) return NULL; if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB)))) - k = safe_calloc (sizeof *k, 1); + k = mem_calloc (sizeof *k, 1); break; } @@ -246,7 +246,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k) debug_print (2, ("user ID: %s\n", p)); - uid = safe_calloc (sizeof (pgp_uid_t), 1); + uid = mem_calloc (sizeof (pgp_uid_t), 1); fix_uid (p); uid->addr = str_dup (p); uid->trust = trust; diff --git a/handler.c b/handler.c index a30ecd4..8373635 100644 --- a/handler.c +++ b/handler.c @@ -559,7 +559,7 @@ static void enriched_flush (struct enriched_state *stte, int wrap) stte->line_used += stte->buff_used; if (stte->line_used > stte->line_max) { stte->line_max = stte->line_used; - safe_realloc (&stte->line, stte->line_max + 1); + mem_realloc (&stte->line, stte->line_max + 1); } strcat (stte->line, stte->buffer); /* __STRCAT_CHECKED__ */ stte->line_len += stte->word_len; @@ -576,7 +576,7 @@ static void enriched_putc (int c, struct enriched_state *stte) if (stte->tag_level[RICH_PARAM]) { if (stte->tag_level[RICH_COLOR]) { if (stte->param_used + 1 >= stte->param_len) - safe_realloc (&stte->param, (stte->param_len += STRING)); + mem_realloc (&stte->param, (stte->param_len += STRING)); stte->param[stte->param_used++] = c; } @@ -586,7 +586,7 @@ static void enriched_putc (int c, struct enriched_state *stte) /* see if more space is needed (plus extra for possible rich characters) */ if (stte->buff_len < stte->buff_used + 3) { stte->buff_len += LONG_STRING; - safe_realloc (&stte->buffer, stte->buff_len + 1); + mem_realloc (&stte->buffer, stte->buff_len + 1); } if ((!stte->tag_level[RICH_NOFILL] && ISSPACE (c)) || c == '\0') { @@ -633,7 +633,7 @@ static void enriched_puts (char *s, struct enriched_state *stte) if (stte->buff_len < stte->buff_used + str_len (s)) { stte->buff_len += LONG_STRING; - safe_realloc (&stte->buffer, stte->buff_len + 1); + mem_realloc (&stte->buffer, stte->buff_len + 1); } c = s; while (*c) { @@ -727,8 +727,8 @@ void text_enriched_handler (BODY * a, STATE * s) ((s->flags & M_DISPLAY) ? (COLS - 4) : ((COLS - 4) < 72) ? (COLS - 4) : 72); stte.line_max = stte.WrapMargin * 4; - stte.line = (char *) safe_calloc (1, stte.line_max + 1); - stte.param = (char *) safe_calloc (1, STRING); + stte.line = (char *) mem_calloc (1, stte.line_max + 1); + stte.param = (char *) mem_calloc (1, STRING); stte.param_len = STRING; stte.param_used = 0; @@ -819,9 +819,9 @@ void text_enriched_handler (BODY * a, STATE * s) state_putc ('\n', s); /* add a final newline */ - FREE (&(stte.buffer)); - FREE (&(stte.line)); - FREE (&(stte.param)); + mem_free (&(stte.buffer)); + mem_free (&(stte.line)); + mem_free (&(stte.param)); } /* @@ -976,7 +976,7 @@ static void text_plain_flowed_handler (BODY * a, STATE * s) else { print_flowed_line (curline, s, quotelevel); } - FREE (&curline); + mem_free (&curline); curline_len = 1; curline = realloc (curline, curline_len + str_len (buf)); if (curline_len == 1) @@ -1002,7 +1002,7 @@ static void text_plain_flowed_handler (BODY * a, STATE * s) } if (curline) { print_flowed_line (curline, s, quotelevel); - FREE (&curline); + mem_free (&curline); } } @@ -1314,7 +1314,7 @@ void autoview_handler (BODY * a, STATE * s) mutt_sanitize_filename (fname, 1); rfc1524_expand_filename (entry->nametemplate, fname, tempfile, sizeof (tempfile)); - FREE (&fname); + mem_free (&fname); if (entry->command) { strfcpy (command, entry->command, sizeof (command)); diff --git a/hash.c b/hash.c index 96a97ac..cb2cf2e 100644 --- a/hash.c +++ b/hash.c @@ -40,13 +40,13 @@ int hash_string (const unsigned char *s, int n) HASH *hash_create (int nelem) { - HASH *table = safe_malloc (sizeof (HASH)); + HASH *table = mem_malloc (sizeof (HASH)); if (nelem == 0) nelem = 2; table->nelem = nelem; table->curnelem = 0; - table->table = safe_calloc (nelem, sizeof (struct hash_elem *)); + table->table = mem_calloc (nelem, sizeof (struct hash_elem *)); return table; } @@ -63,11 +63,11 @@ HASH *hash_resize (HASH * ptr, int nelem) tmp = elem; elem = elem->next; hash_insert (table, tmp->key, tmp->data, 1); - FREE (&tmp); + mem_free (&tmp); } } - FREE (&ptr->table); - FREE (&ptr); + mem_free (&ptr->table); + mem_free (&ptr); return table; } @@ -82,7 +82,7 @@ int hash_insert (HASH * table, const char *key, void *data, int allow_dup) struct hash_elem *ptr; int h; - ptr = (struct hash_elem *) safe_malloc (sizeof (struct hash_elem)); + ptr = (struct hash_elem *) mem_malloc (sizeof (struct hash_elem)); h = hash_string ((unsigned char *) key, table->nelem); ptr->key = key; ptr->data = data; @@ -99,7 +99,7 @@ int hash_insert (HASH * table, const char *key, void *data, int allow_dup) for (tmp = table->table[h], last = NULL; tmp; last = tmp, tmp = tmp->next) { r = str_cmp (tmp->key, key); if (r == 0) { - FREE (&ptr); + mem_free (&ptr); return (-1); } if (r > 0) @@ -137,7 +137,7 @@ void hash_delete_hash (HASH * table, int hash, const char *key, const void *data *last = ptr->next; if (destroy) destroy (ptr->data); - FREE (&ptr); + mem_free (&ptr); ptr = *last; } else { @@ -162,9 +162,9 @@ void hash_destroy (HASH ** ptr, void (*destroy) (void *)) elem = elem->next; if (destroy) destroy (tmp->data); - FREE (&tmp); + mem_free (&tmp); } } - FREE (&pptr->table); - FREE (ptr); + mem_free (&pptr->table); + mem_free (ptr); } diff --git a/hcache.c b/hcache.c index 7894dcc..93b84de 100644 --- a/hcache.c +++ b/hcache.c @@ -86,7 +86,7 @@ static void *lazy_malloc (size_t siz) siz = 4096; } - return safe_malloc (siz); + return mem_malloc (siz); } static void lazy_realloc (void *ptr, size_t siz) @@ -97,7 +97,7 @@ static void lazy_realloc (void *ptr, size_t siz) return; } - safe_realloc (ptr, siz); + mem_realloc (ptr, siz); } static unsigned char *dump_int (unsigned int i, unsigned char *d, int *off) @@ -164,7 +164,7 @@ static void restore_char (char **c, const unsigned char *d, int *off) return; } - *c = safe_malloc (size); + *c = mem_malloc (size); memcpy (*c, d + *off, size); *off += size; } @@ -196,7 +196,7 @@ static void restore_address (ADDRESS ** a, const unsigned char *d, int *off) restore_int (&counter, d, off); while (counter) { - *a = safe_malloc (sizeof (ADDRESS)); + *a = mem_malloc (sizeof (ADDRESS)); restore_char (&(*a)->personal, d, off); restore_char (&(*a)->mailbox, d, off); restore_int ((unsigned int *) &(*a)->group, d, off); @@ -232,7 +232,7 @@ static void restore_list (LIST ** l, const unsigned char *d, int *off) restore_int (&counter, d, off); while (counter) { - *l = safe_malloc (sizeof (LIST)); + *l = mem_malloc (sizeof (LIST)); restore_char (&(*l)->data, d, off); l = &(*l)->next; counter--; @@ -270,7 +270,7 @@ static void restore_buffer (BUFFER ** b, const unsigned char *d, int *off) return; } - *b = safe_malloc (sizeof (BUFFER)); + *b = mem_malloc (sizeof (BUFFER)); restore_char (&(*b)->data, d, off); restore_int (&offset, d, off); @@ -308,7 +308,7 @@ restore_parameter (PARAMETER ** p, const unsigned char *d, int *off) restore_int (&counter, d, off); while (counter) { - *p = safe_malloc (sizeof (PARAMETER)); + *p = mem_malloc (sizeof (PARAMETER)); restore_char (&(*p)->attribute, d, off); restore_char (&(*p)->value, d, off); p = &(*p)->next; @@ -604,7 +604,7 @@ HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh) void * mutt_hcache_open(const char *path, const char *folder) { - struct header_cache *h = safe_calloc(1, sizeof (HEADER_CACHE)); + struct header_cache *h = mem_calloc(1, sizeof (HEADER_CACHE)); int flags = VL_OWRITER | VL_OCREAT; h->db = NULL; h->folder = str_dup(folder); @@ -612,8 +612,8 @@ mutt_hcache_open(const char *path, const char *folder) if (!path || path[0] == '\0') { - FREE(&h->folder); - FREE(&h); + mem_free(&h->folder); + mem_free(&h); return NULL; } @@ -627,8 +627,8 @@ mutt_hcache_open(const char *path, const char *folder) return h; else { - FREE(&h->folder); - FREE(&h); + mem_free(&h->folder); + mem_free(&h); return NULL; } @@ -643,8 +643,8 @@ mutt_hcache_close(void *db) return; vlclose(h->db); - FREE(&h->folder); - FREE(&h); + mem_free(&h->folder); + mem_free(&h); } void * @@ -668,7 +668,7 @@ mutt_hcache_fetch(void *db, const char *filename, if (! crc32_matches(data, h->crc)) { - FREE(&data); + mem_free(&data); return NULL; } @@ -698,7 +698,7 @@ mutt_hcache_store(void *db, const char *filename, HEADER * header, ret = vlput(h->db, path, ksize, data, dsize, VL_DOVER); - FREE(&data); + mem_free(&data); return ret; } @@ -726,7 +726,7 @@ mutt_hcache_delete(void *db, const char *filename, void *mutt_hcache_open (const char *path, const char *folder) { - struct header_cache *h = safe_calloc (1, sizeof (HEADER_CACHE)); + struct header_cache *h = mem_calloc (1, sizeof (HEADER_CACHE)); int pagesize = atoi (HeaderCachePageSize) ? atoi (HeaderCachePageSize) : 16384; h->db = NULL; @@ -734,8 +734,8 @@ void *mutt_hcache_open (const char *path, const char *folder) h->crc = generate_crc32 (); if (!path || path[0] == '\0') { - FREE (&h->folder); - FREE (&h); + mem_free (&h->folder); + mem_free (&h); return NULL; } @@ -752,8 +752,8 @@ void *mutt_hcache_open (const char *path, const char *folder) return h; } else { - FREE (&h->folder); - FREE (&h); + mem_free (&h->folder); + mem_free (&h); return NULL; } @@ -768,8 +768,8 @@ void mutt_hcache_close (void *db) } gdbm_close (h->db); - FREE (&h->folder); - FREE (&h); + mem_free (&h->folder); + mem_free (&h); } void *mutt_hcache_fetch (void *db, const char *filename, @@ -793,7 +793,7 @@ void *mutt_hcache_fetch (void *db, const char *filename, data = gdbm_fetch (h->db, key); if (!crc32_matches (data.dptr, h->crc)) { - FREE(&data.dptr); + mem_free(&data.dptr); return NULL; } @@ -824,7 +824,7 @@ mutt_hcache_store (void *db, const char *filename, HEADER * header, ret = gdbm_store (h->db, key, data, GDBM_REPLACE); - FREE (&data.dptr); + mem_free (&data.dptr); return ret; } @@ -878,7 +878,7 @@ void *mutt_hcache_open (const char *path, const char *folder) h->crc = generate_crc32 (); if (!path || path[0] == '\0') { - FREE (&h); + mem_free (&h); return NULL; } @@ -888,13 +888,13 @@ void *mutt_hcache_open (const char *path, const char *folder) h->fd = open (h->lockfile, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (h->fd < 0) { - FREE (&h); + mem_free (&h); return NULL; } if (mx_lock_file (h->lockfile, h->fd, 1, 0, 5)) { close (h->fd); - FREE (&h); + mem_free (&h); return NULL; } @@ -902,7 +902,7 @@ void *mutt_hcache_open (const char *path, const char *folder) if (ret) { mx_unlock_file (h->lockfile, h->fd, 0); close (h->fd); - FREE (&h); + mem_free (&h); return NULL; } @@ -914,7 +914,7 @@ void *mutt_hcache_open (const char *path, const char *folder) h->env->close (h->env, 0); mx_unlock_file (h->lockfile, h->fd, 0); close (h->fd); - FREE (&h); + mem_free (&h); return NULL; } } @@ -930,7 +930,7 @@ void *mutt_hcache_open (const char *path, const char *folder) h->env->close (h->env, 0); mx_unlock_file (h->lockfile, h->fd, 0); close (h->fd); - FREE (&h); + mem_free (&h); return NULL; } @@ -949,7 +949,7 @@ void mutt_hcache_close (void *db) h->env->close (h->env, 0); mx_unlock_file (h->lockfile, h->fd, 0); close (h->fd); - FREE (&h); + mem_free (&h); } void *mutt_hcache_fetch (void *db, const char *filename, @@ -972,7 +972,7 @@ void *mutt_hcache_fetch (void *db, const char *filename, h->db->get (h->db, NULL, &key, &data, 0); if (!crc32_matches (data.data, h->crc)) { - FREE(&data.data); + mem_free(&data.data); return NULL; } @@ -1004,7 +1004,7 @@ mutt_hcache_store (void *db, const char *filename, HEADER * header, ret = h->db->put (h->db, NULL, &key, &data, 0); - FREE (&data.data); + mem_free (&data.data); return ret; } diff --git a/history.c b/history.c index fba9618..d61d0ce 100644 --- a/history.c +++ b/history.c @@ -33,13 +33,13 @@ static void init_history (struct history *h) if (OldSize) { if (h->hist) { for (i = 0; i < OldSize; i++) - FREE (&h->hist[i]); - FREE (&h->hist); + mem_free (&h->hist[i]); + mem_free (&h->hist); } } if (HistSize) - h->hist = safe_calloc (HistSize, sizeof (char *)); + h->hist = mem_calloc (HistSize, sizeof (char *)); h->cur = 0; h->last = 0; diff --git a/hook.c b/hook.c index 0711ca7..a87dac9 100644 --- a/hook.c +++ b/hook.c @@ -86,7 +86,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, if (data & (M_FOLDERHOOK | M_MBOXHOOK)) { strfcpy (path, pattern.data, sizeof (path)); _mutt_expand_path (path, sizeof (path), 1); - FREE (&pattern.data); + mem_free (&pattern.data); memset (&pattern, 0, sizeof (pattern)); pattern.data = str_dup (path); } @@ -105,7 +105,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, strfcpy (tmp, pattern.data, sizeof (tmp)); mutt_check_simple (tmp, sizeof (tmp), DefaultHook); - FREE (&pattern.data); + mem_free (&pattern.data); memset (&pattern, 0, sizeof (pattern)); pattern.data = str_dup (tmp); } @@ -113,7 +113,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, if (data & (M_MBOXHOOK | M_SAVEHOOK | M_FCCHOOK)) { strfcpy (path, command.data, sizeof (path)); mutt_expand_path (path, sizeof (path)); - FREE (&command.data); + mem_free (&command.data); memset (&command, 0, sizeof (command)); command.data = str_dup (path); } @@ -129,8 +129,8 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, * pattern, so if we've already seen this pattern/command pair, just * ignore it instead of creating a duplicate */ if (!str_cmp (ptr->command, command.data)) { - FREE (&command.data); - FREE (&pattern.data); + mem_free (&command.data); + mem_free (&pattern.data); return 0; } } @@ -140,9 +140,9 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, * order of execution of the hooks, which i think is desirable since * a common action to perform is to change the default (.) entry * based upon some other information. */ - FREE (&ptr->command); + mem_free (&ptr->command); ptr->command = command.data; - FREE (&pattern.data); + mem_free (&pattern.data); return 0; } } @@ -160,7 +160,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, goto error; } else { - rx = safe_malloc (sizeof (regex_t)); + rx = mem_malloc (sizeof (regex_t)); #ifdef M_CRYPTHOOK if ((rc = REGCOMP (rx, NONULL (pattern.data), @@ -175,17 +175,17 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, { regerror (rc, rx, err->data, err->dsize); regfree (rx); - FREE (&rx); + mem_free (&rx); goto error; } } if (ptr) { - ptr->next = safe_calloc (1, sizeof (HOOK)); + ptr->next = mem_calloc (1, sizeof (HOOK)); ptr = ptr->next; } else - Hooks = ptr = safe_calloc (1, sizeof (HOOK)); + Hooks = ptr = mem_calloc (1, sizeof (HOOK)); ptr->type = data; ptr->command = command.data; ptr->pattern = pat; @@ -195,20 +195,20 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, return 0; error: - FREE (&pattern.data); - FREE (&command.data); + mem_free (&pattern.data); + mem_free (&command.data); return (-1); } static void delete_hook (HOOK * h) { - FREE (&h->command); - FREE (&h->rx.pattern); + mem_free (&h->command); + mem_free (&h->rx.pattern); if (h->rx.rx) { regfree (h->rx.rx); } mutt_pattern_free (&h->pattern); - FREE (&h); + mem_free (&h); } /* Deletes all hooks of type ``type'', or all defined hooks if ``type'' is 0 */ @@ -287,7 +287,7 @@ void mutt_folder_hook (char *path) if ((regexec (tmp->rx.rx, path, 0, NULL, 0) == 0) ^ tmp->rx.not) { if (mutt_parse_rc_line (tmp->command, &token, &err) == -1) { mutt_error ("%s", err.data); - FREE (&token.data); + mem_free (&token.data); mutt_sleep (1); /* pause a moment to let the user see the error */ current_hook_type = 0; return; @@ -295,7 +295,7 @@ void mutt_folder_hook (char *path) } } } - FREE (&token.data); + mem_free (&token.data); current_hook_type = 0; } @@ -330,14 +330,14 @@ void mutt_message_hook (CONTEXT * ctx, HEADER * hdr, int type) if (hook->type & type) if ((mutt_pattern_exec (hook->pattern, 0, ctx, hdr) > 0) ^ hook->rx.not) if (mutt_parse_rc_line (hook->command, &token, &err) != 0) { - FREE (&token.data); + mem_free (&token.data); mutt_error ("%s", err.data); mutt_sleep (1); current_hook_type = 0; return; } } - FREE (&token.data); + mem_free (&token.data); current_hook_type = 0; } @@ -455,7 +455,7 @@ void mutt_account_hook (const char *url) if ((regexec (hook->rx.rx, url, 0, NULL, 0) == 0) ^ hook->rx.not) { if (mutt_parse_rc_line (hook->command, &token, &err) == -1) { - FREE (&token.data); + mem_free (&token.data); mutt_error ("%s", err.data); mutt_sleep (1); @@ -464,6 +464,6 @@ void mutt_account_hook (const char *url) } } - FREE (&token.data); + mem_free (&token.data); } #endif diff --git a/imap/auth.c b/imap/auth.c index f5af43f..6ec3c1b 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -70,7 +70,7 @@ int imap_authenticate (IMAP_DATA * idata) !ascii_strcasecmp (authenticator->method, method)) if ((r = authenticator->authenticate (idata, method)) != IMAP_AUTH_UNAVAIL) { - FREE (&methods); + mem_free (&methods); return r; } @@ -78,7 +78,7 @@ int imap_authenticate (IMAP_DATA * idata) } } - FREE (&methods); + mem_free (&methods); } else { /* Fall back to default: any authenticator */ diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 905075a..e0fbfba 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -161,7 +161,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) /* sasl_client_st(art|ep) allocate pc with malloc, expect me to * free it */ #ifndef USE_SASL2 - FREE (&pc); + mem_free (&pc); #endif } diff --git a/imap/browse.c b/imap/browse.c index 30eb5e6..0f23e21 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -223,11 +223,11 @@ int imap_browse (char *path, struct browser_state *state) } } - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; fail: - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -274,11 +274,11 @@ int imap_mailbox_create (const char *folder) mutt_sleep (0); - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; fail: - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -319,11 +319,11 @@ int imap_mailbox_rename (const char *mailbox) mutt_message (_("Mailbox renamed.")); mutt_sleep (0); - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; fail: - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -346,7 +346,7 @@ static int browse_add_list_result (IMAP_DATA * idata, const char *cmd, do { if (imap_parse_list_response (idata, &name, &noselect, &noinferiors, &idata->delim) != 0) { - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -362,7 +362,7 @@ static int browse_add_list_result (IMAP_DATA * idata, const char *cmd, } while ((ascii_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0)); - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; } @@ -382,7 +382,7 @@ static void imap_add_folder (char delim, char *folder, int noselect, imap_unmunge_mbox_name (folder); if (state->entrylen + 1 == state->entrymax) { - safe_realloc (&state->entry, + mem_realloc (&state->entry, sizeof (struct folder_file) * (state->entrymax += 256)); memset (state->entry + state->entrylen, 0, (sizeof (struct folder_file) * @@ -402,7 +402,7 @@ static void imap_add_folder (char delim, char *folder, int noselect, * than at scan, since it's so expensive to scan. But that's big changes * to browser.c */ if (!((regexec (Mask.rx, relpath, 0, NULL, 0) == 0) ^ Mask.not)) { - FREE (&mx.mbox); + mem_free (&mx.mbox); return; } @@ -426,7 +426,7 @@ static void imap_add_folder (char delim, char *folder, int noselect, (state->entry)[state->entrylen].inferiors = !noinferiors; (state->entrylen)++; - FREE (&mx.mbox); + mem_free (&mx.mbox); } static int compare_names (struct folder_file *a, struct folder_file *b) diff --git a/imap/command.c b/imap/command.c index ebf468e..f76cff6 100644 --- a/imap/command.c +++ b/imap/command.c @@ -71,12 +71,12 @@ int imap_cmd_start (IMAP_DATA * idata, const char *cmd) cmd_make_sequence (idata); /* seq, space, cmd, \r\n\0 */ outlen = str_len (idata->cmd.seq) + str_len (cmd) + 4; - out = (char *) safe_malloc (outlen); + out = (char *) mem_malloc (outlen); snprintf (out, outlen, "%s %s\r\n", idata->cmd.seq, cmd); rc = mutt_socket_write (idata->conn, out); - FREE (&out); + mem_free (&out); return (rc < 0) ? IMAP_CMD_BAD : 0; } @@ -100,7 +100,7 @@ int imap_cmd_step (IMAP_DATA * idata) * line */ do { if (len == cmd->blen) { - safe_realloc (&cmd->buf, cmd->blen + IMAP_CMD_BUFSIZE); + mem_realloc (&cmd->buf, cmd->blen + IMAP_CMD_BUFSIZE); cmd->blen = cmd->blen + IMAP_CMD_BUFSIZE; debug_print (3, ("grew buffer to %u bytes\n", cmd->blen)); } @@ -121,7 +121,7 @@ int imap_cmd_step (IMAP_DATA * idata) /* don't let one large string make cmd->buf hog memory forever */ if ((cmd->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE)) { - safe_realloc (&cmd->buf, IMAP_CMD_BUFSIZE); + mem_realloc (&cmd->buf, IMAP_CMD_BUFSIZE); cmd->blen = IMAP_CMD_BUFSIZE; debug_print (3, ("shrank buffer to %u bytes\n", cmd->blen)); } @@ -183,13 +183,13 @@ int imap_exec (IMAP_DATA * idata, const char *cmd, int flags) cmd_make_sequence (idata); /* seq, space, cmd, \r\n\0 */ outlen = str_len (idata->cmd.seq) + str_len (cmd) + 4; - out = (char *) safe_malloc (outlen); + out = (char *) mem_malloc (outlen); snprintf (out, outlen, "%s %s\r\n", idata->cmd.seq, cmd); rc = mutt_socket_write_d (idata->conn, out, flags & IMAP_CMD_PASS ? IMAP_LOG_PASS : IMAP_LOG_CMD); - FREE (&out); + mem_free (&out); if (rc < 0) { cmd_handle_fatal (idata); @@ -394,7 +394,7 @@ static void cmd_parse_capabilities (IMAP_DATA * idata, char *s) debug_print (2, ("Handling CAPABILITY\n")); s = imap_next_word (s); - FREE (&idata->capstr); + mem_free (&idata->capstr); idata->capstr = str_dup (s); memset (idata->capabilities, 0, sizeof (idata->capabilities)); diff --git a/imap/imap.c b/imap/imap.c index 0abf32b..243df3a 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -65,7 +65,7 @@ int imap_access (const char *path, int flags) if (!(idata = imap_conn_find (&mx.account, option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW : 0))) { - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -73,11 +73,11 @@ int imap_access (const char *path, int flags) /* we may already be in the folder we're checking */ if (!ascii_strcmp(idata->mailbox, mx.mbox)) { - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; } - FREE (&mx.mbox); + mem_free (&mx.mbox); imap_munge_mbox_name (mbox, sizeof (mbox), mailbox); if (mutt_bit_isset (idata->capabilities, IMAP4REV1)) @@ -137,7 +137,7 @@ int imap_delete_mailbox (CONTEXT * ctx, IMAP_MBOX mx) if (!(idata = imap_conn_find (&mx.account, option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW : 0))) { - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } } @@ -240,7 +240,7 @@ void imap_expunge_mailbox (IMAP_DATA * idata) if (idata->cache[cacheno].uid == HEADER_DATA (h)->uid && idata->cache[cacheno].path) { unlink (idata->cache[cacheno].path); - FREE (&idata->cache[cacheno].path); + mem_free (&idata->cache[cacheno].path); } imap_free_header_data (&h->data); @@ -382,7 +382,7 @@ IMAP_DATA *imap_conn_find (const ACCOUNT * account, int flags) else mutt_account_unsetpass (&idata->conn->account); - FREE (&idata->capstr); + mem_free (&idata->capstr); } if (idata->state == IMAP_AUTHENTICATED) imap_get_delim (idata); @@ -454,7 +454,7 @@ int imap_open_connection (IMAP_DATA * idata) idata->state = IMAP_AUTHENTICATED; if (imap_check_capabilities (idata) != 0) goto bail; - FREE (&idata->capstr); + mem_free (&idata->capstr); } else { imap_error ("imap_open_connection()", buf); @@ -467,7 +467,7 @@ err_close_conn: mutt_socket_close (idata->conn); idata->state = IMAP_DISCONNECTED; bail: - FREE (&idata->capstr); + mem_free (&idata->capstr); return -1; } @@ -549,11 +549,11 @@ int imap_open_mailbox (CONTEXT * ctx) /* Clean up path and replace the one in the ctx */ imap_fix_path (idata, mx.mbox, buf, sizeof (buf)); - FREE (&(idata->mailbox)); + mem_free (&(idata->mailbox)); idata->mailbox = str_dup (buf); imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox); - FREE (&(ctx->path)); + mem_free (&(ctx->path)); ctx->path = str_dup (buf); idata->ctx = ctx; @@ -682,8 +682,8 @@ int imap_open_mailbox (CONTEXT * ctx) } ctx->hdrmax = count; - ctx->hdrs = safe_calloc (count, sizeof (HEADER *)); - ctx->v2r = safe_calloc (count, sizeof (int)); + ctx->hdrs = mem_calloc (count, sizeof (HEADER *)); + ctx->v2r = mem_calloc (count, sizeof (int)); ctx->msgcount = 0; if (count && (imap_read_headers (idata, 0, count - 1) < 0)) { mutt_error _("Error opening mailbox"); @@ -693,14 +693,14 @@ int imap_open_mailbox (CONTEXT * ctx) } debug_print (2, ("msgcount is %d\n", ctx->msgcount)); - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; fail: if (idata->state == IMAP_SELECTED) idata->state = IMAP_AUTHENTICATED; fail_noidata: - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -719,7 +719,7 @@ int imap_open_mailbox_append (CONTEXT * ctx) * ctx is brand new and mostly empty */ if (!(idata = imap_conn_find (&(mx.account), 0))) { - FREE(&mx.mbox); + mem_free(&mx.mbox); return (-1); } conn = idata->conn; @@ -729,7 +729,7 @@ int imap_open_mailbox_append (CONTEXT * ctx) imap_fix_path (idata, mx.mbox, mailbox, sizeof (mailbox)); - FREE(&mx.mbox); + mem_free(&mx.mbox); /* really we should also check for W_OK */ if (!imap_access (ctx->path, F_OK)) @@ -753,8 +753,8 @@ void imap_logout (IMAP_DATA * idata) idata->status = IMAP_BYE; imap_cmd_start (idata, "LOGOUT"); while (imap_cmd_step (idata) == IMAP_CMD_CONTINUE); - FREE (&idata->cmd.buf); - FREE (&idata); + mem_free (&idata->cmd.buf); + mem_free (&idata); } /* @@ -806,7 +806,7 @@ int imap_make_msg_set (IMAP_DATA * idata, BUFFER * buf, int flag, int changed) int started = 0; /* make copy of header pointers to sort in natural order */ - hdrs = safe_calloc (idata->ctx->msgcount, sizeof (HEADER *)); + hdrs = mem_calloc (idata->ctx->msgcount, sizeof (HEADER *)); memcpy (hdrs, idata->ctx->hdrs, idata->ctx->msgcount * sizeof (HEADER *)); if (Sort != SORT_ORDER) { @@ -862,7 +862,7 @@ int imap_make_msg_set (IMAP_DATA * idata, BUFFER * buf, int flag, int changed) } } - FREE (&hdrs); + mem_free (&hdrs); return count; } @@ -1045,10 +1045,10 @@ int imap_sync_mailbox (CONTEXT * ctx, int expunge, int *index_hint) rc = 0; out: if (cmd.data) - FREE (&cmd.data); + mem_free (&cmd.data); if (appendctx) { mx_fastclose_mailbox (appendctx); - FREE (&appendctx); + mem_free (&appendctx); } return rc; } @@ -1074,7 +1074,7 @@ void imap_close_mailbox (CONTEXT * ctx) } idata->reopen &= IMAP_REOPEN_ALLOW; - FREE (&(idata->mailbox)); + mem_free (&(idata->mailbox)); mutt_free_list (&idata->flags); idata->ctx = NULL; } @@ -1086,7 +1086,7 @@ void imap_close_mailbox (CONTEXT * ctx) for (i = 0; i < IMAP_CACHE_LEN; i++) { if (idata->cache[i].path) { unlink (idata->cache[i].path); - FREE (&idata->cache[i].path); + mem_free (&idata->cache[i].path); } } } @@ -1155,13 +1155,13 @@ int imap_mailbox_check (char *path, int new) connflags = M_IMAP_CONN_NONEW; if (!(idata = imap_conn_find (&(mx.account), connflags))) { - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } conn = idata->conn; imap_fix_path (idata, mx.mbox, buf, sizeof (buf)); - FREE (&mx.mbox); + mem_free (&mx.mbox); imap_munge_mbox_name (mbox, sizeof (mbox), buf); strfcpy (mbox_unquoted, buf, sizeof (mbox_unquoted)); @@ -1323,11 +1323,11 @@ int imap_subscribe (char *path, int subscribe) if (imap_exec (idata, buf, 0) < 0) goto fail; - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; fail: - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -1414,7 +1414,7 @@ int imap_complete (char *dest, size_t dlen, char *path) { /* don't open a new socket just for completion. Instead complete over * known mailboxes/hooks/etc */ if (!(idata = imap_conn_find (&(mx.account), M_IMAP_CONN_NONEW))) { - FREE (&mx.mbox); + mem_free (&mx.mbox); strfcpy (dest, path, dlen); return imap_complete_hosts (dest, dlen); } @@ -1470,7 +1470,7 @@ int imap_complete (char *dest, size_t dlen, char *path) { imap_qualify_path (dest, dlen, &mx, completion); mutt_pretty_mailbox (dest); - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; } diff --git a/imap/message.c b/imap/message.c index e09ec4e..416ca73 100644 --- a/imap/message.c +++ b/imap/message.c @@ -128,7 +128,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) rewind (fp); memset (&h, 0, sizeof (h)); - h.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA)); + h.data = mem_calloc (1, sizeof (IMAP_HEADER_DATA)); do { mfhrc = 0; @@ -171,7 +171,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) rewind (fp); - FREE (&uid_validity); + mem_free (&uid_validity); } while ((rc != IMAP_CMD_OK) && ((mfhrc == -1) || @@ -218,7 +218,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) /* freshen fp, h */ rewind (fp); memset (&h, 0, sizeof (h)); - h.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA)); + h.data = mem_calloc (1, sizeof (IMAP_HEADER_DATA)); /* this DO loop does two things: * 1. handles untagged messages, so we can try again on the same msg @@ -340,7 +340,7 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) return 0; else { unlink (cache->path); - FREE (&cache->path); + mem_free (&cache->path); } } @@ -351,7 +351,7 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) mutt_mktemp (path); cache->path = str_dup (path); if (!(msg->fp = safe_fopen (path, "w+"))) { - FREE (&cache->path); + mem_free (&cache->path); return -1; } @@ -472,7 +472,7 @@ bail: safe_fclose (&msg->fp); if (cache->path) { unlink (cache->path); - FREE (&cache->path); + mem_free (&cache->path); } return -1; @@ -579,11 +579,11 @@ int imap_append_message (CONTEXT * ctx, MESSAGE * msg) goto fail; } - FREE (&mx.mbox); + mem_free (&mx.mbox); return 0; fail: - FREE (&mx.mbox); + mem_free (&mx.mbox); return -1; } @@ -725,18 +725,18 @@ int imap_copy_messages (CONTEXT * ctx, HEADER * h, char *dest, int delete) } if (cmd.data) - FREE (&cmd.data); + mem_free (&cmd.data); if (sync_cmd.data) - FREE (&sync_cmd.data); - FREE (&mx.mbox); + mem_free (&sync_cmd.data); + mem_free (&mx.mbox); return 0; fail: if (cmd.data) - FREE (&cmd.data); + mem_free (&cmd.data); if (sync_cmd.data) - FREE (&sync_cmd.data); - FREE (&mx.mbox); + mem_free (&sync_cmd.data); + mem_free (&mx.mbox); return -1; } @@ -767,7 +767,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)); - FREE (data); + mem_free (data); } /* imap_set_flags: fill out the message header according to the flags from @@ -779,11 +779,11 @@ char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s) unsigned char readonly; memset (&newh, 0, sizeof (newh)); - newh.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA)); + newh.data = mem_calloc (1, sizeof (IMAP_HEADER_DATA)); debug_print (2, ("parsing FLAGS\n")); if ((s = msg_parse_flags (&newh, s)) == NULL) { - FREE (&newh.data); + mem_free (&newh.data); return NULL; } @@ -809,7 +809,7 @@ char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s) mutt_free_list (&(HEADER_DATA (h)->keywords)); HEADER_DATA (h)->keywords = newh.data->keywords; - FREE (&newh.data); + mem_free (&newh.data); return s; } diff --git a/imap/mx_imap.c b/imap/mx_imap.c index cf04c19..6ad4b32 100644 --- a/imap/mx_imap.c +++ b/imap/mx_imap.c @@ -61,7 +61,7 @@ static int imap_commit_message (MESSAGE* msg, CONTEXT* ctx) { } mx_t* imap_reg_mx (void) { - mx_t* fmt = safe_calloc (1, sizeof (mx_t)); + mx_t* fmt = mem_calloc (1, sizeof (mx_t)); /* make up mx_t record... */ fmt->type = M_IMAP; diff --git a/imap/utf7.c b/imap/utf7.c index 589a661..8d7d206 100644 --- a/imap/utf7.c +++ b/imap/utf7.c @@ -52,7 +52,7 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8, char *buf, *p; int b, ch, k; - p = buf = safe_malloc (u7len + u7len / 8 + 1); + p = buf = mem_malloc (u7len + u7len / 8 + 1); for (; u7len; u7++, u7len--) { if (*u7 == '&') { @@ -113,13 +113,13 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8, if (u8len) *u8len = p - buf; - safe_realloc (&buf, p - buf); + mem_realloc (&buf, p - buf); if (u8) *u8 = buf; return buf; bail: - FREE (&buf); + mem_free (&buf); return 0; } @@ -142,7 +142,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7, * In the worst case we convert 2 chars to 7 chars. For example: * "\x10&\x10&..." -> "&ABA-&-&ABA-&-...". */ - p = buf = safe_malloc ((u8len / 2) * 7 + 6); + p = buf = mem_malloc ((u8len / 2) * 7 + 6); while (u8len) { unsigned char c = *u8; @@ -206,7 +206,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7, } if (u8len) { - FREE (&buf); + mem_free (&buf); return 0; } @@ -219,13 +219,13 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7, *p++ = '\0'; if (u7len) *u7len = p - buf; - safe_realloc (&buf, p - buf); + mem_realloc (&buf, p - buf); if (u7) *u7 = buf; return buf; bail: - FREE (&buf); + mem_free (&buf); return 0; } @@ -236,7 +236,7 @@ void imap_utf7_encode (char **s) if (!mutt_convert_string (&t, Charset, "UTF-8", 0)) utf8_to_utf7 (t, str_len (t), s, 0); - FREE (&t); + mem_free (&t); } } @@ -246,7 +246,7 @@ void imap_utf7_decode (char **s) char *t = utf7_to_utf8 (*s, str_len (*s), 0, 0); if (t && !mutt_convert_string (&t, "UTF-8", Charset, 0)) { - FREE (s); + mem_free (s); *s = t; } } diff --git a/imap/util.c b/imap/util.c index 0e842b1..ecf5d53 100644 --- a/imap/util.c +++ b/imap/util.c @@ -56,7 +56,7 @@ int imap_expand_path (char *path, size_t len) url.path = mx.mbox; rc = url_ciss_tostring (&url, path, len, U_DECODE_PASSWD); - FREE (&mx.mbox); + mem_free (&mx.mbox); return rc; } @@ -99,7 +99,7 @@ int imap_parse_path (const char *path, IMAP_MBOX * mx) if (!(url.scheme == U_IMAP || url.scheme == U_IMAPS) || mutt_account_fromurl (&mx->account, &url) < 0) { - FREE (&c); + mem_free (&c); return -1; } @@ -108,7 +108,7 @@ int imap_parse_path (const char *path, IMAP_MBOX * mx) if (url.scheme == U_IMAPS) mx->account.flags |= M_ACCT_SSL; - FREE (&c); + mem_free (&c); if ((mx->account.flags & M_ACCT_SSL) && !(mx->account.flags & M_ACCT_PORT)) mx->account.port = ImapsPort; @@ -143,7 +143,7 @@ void imap_pretty_mailbox (char *path) if (target.mbox[hlen] == *delim) home_match = 1; } - FREE (&home.mbox); + mem_free (&home.mbox); } /* do the '=' substitution */ @@ -164,7 +164,7 @@ void imap_pretty_mailbox (char *path) url_ciss_tostring (&url, path, 1024, 0); } - FREE (&target.mbox); + mem_free (&target.mbox); } /* -- library functions -- */ @@ -188,7 +188,7 @@ void imap_error (const char *where, const char *msg) * Returns NULL on failure (no mem) */ IMAP_DATA *imap_new_idata (void) { - return safe_calloc (1, sizeof (IMAP_DATA)); + return mem_calloc (1, sizeof (IMAP_DATA)); } /* imap_free_idata: Release and clear storage in an IMAP_DATA structure. */ @@ -197,10 +197,10 @@ void imap_free_idata (IMAP_DATA ** idata) if (!idata) return; - FREE (&(*idata)->capstr); + mem_free (&(*idata)->capstr); mutt_free_list (&(*idata)->flags); - FREE (&((*idata)->cmd.buf)); - FREE (idata); + mem_free (&((*idata)->cmd.buf)); + mem_free (idata); } /* @@ -429,7 +429,7 @@ void imap_munge_mbox_name (char *dest, size_t dlen, const char *src) imap_quote_string (dest, dlen, buf); - FREE (&buf); + mem_free (&buf); } void imap_unmunge_mbox_name (char *s) @@ -444,7 +444,7 @@ void imap_unmunge_mbox_name (char *s) strncpy (s, buf, str_len (s)); } - FREE (&buf); + mem_free (&buf); } /* imap_wordcasecmp: find word a in word list b */ @@ -494,12 +494,12 @@ void imap_keepalive (void) if (idata->ctx) ctx = idata->ctx; else { - ctx = safe_calloc (1, sizeof (CONTEXT)); + ctx = mem_calloc (1, sizeof (CONTEXT)); ctx->data = idata; } imap_check_mailbox (ctx, NULL, 1); if (!idata->ctx) - FREE (&ctx); + mem_free (&ctx); } } diff --git a/init.c b/init.c index ff8c03b..0a0d9ab 100644 --- a/init.c +++ b/init.c @@ -60,7 +60,7 @@ int CurRCLine = 0; /* for synonym warning reports: adds synonym to end of list */ static void syn_add (int n, int o) { - syn_t* tmp = safe_malloc (sizeof (syn_t)); + syn_t* tmp = mem_malloc (sizeof (syn_t)); tmp->f = str_dup (CurRCFile); tmp->l = CurRCLine; tmp->n = n; @@ -70,8 +70,8 @@ static void syn_add (int n, int o) { /* for synonym warning reports: free single item (for list_del()) */ static void syn_del (void** p) { - FREE(&(*(syn_t**) p)->f); - FREE(p); + mem_free(&(*(syn_t**) p)->f); + mem_free(p); } void toggle_quadoption (int opt) @@ -238,10 +238,10 @@ int mutt_extract_token (BUFFER * dest, BUFFER * tok, int flags) cmd = str_substrdup (tok->dptr, pc); if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) { debug_print (1, ("unable to fork command: %s\n", cmd)); - FREE (&cmd); + mem_free (&cmd); return (-1); } - FREE (&cmd); + mem_free (&cmd); tok->dptr = pc + 1; @@ -257,21 +257,21 @@ int mutt_extract_token (BUFFER * dest, BUFFER * tok, int flags) * the token */ if (expn.data && qc) { mutt_buffer_addstr (dest, expn.data); - FREE (&expn.data); + mem_free (&expn.data); } else if (expn.data) { expnlen = str_len (expn.data); tok->dsize = expnlen + str_len (tok->dptr) + 1; - ptr = safe_malloc (tok->dsize); + ptr = mem_malloc (tok->dsize); memcpy (ptr, expn.data, expnlen); strcpy (ptr + expnlen, tok->dptr); /* __STRCPY_CHECKED__ */ if (tok->destroy) - FREE (&tok->data); + mem_free (&tok->data); tok->data = ptr; tok->dptr = ptr; tok->destroy = 1; /* mark that the caller should destroy this data */ ptr = NULL; - FREE (&expn.data); + mem_free (&expn.data); } } else if (ch == '$' && (!qc || qc == '"') @@ -293,7 +293,7 @@ int mutt_extract_token (BUFFER * dest, BUFFER * tok, int flags) } if (var && (env = getenv (var))) mutt_buffer_addstr (dest, env); - FREE (&var); + mem_free (&var); } else mutt_buffer_addch (dest, ch); @@ -323,7 +323,7 @@ static void add_to_list (LIST ** list, const char *str) } if (!*list || last) { - t = (LIST *) safe_calloc (1, sizeof (LIST)); + t = (LIST *) mem_calloc (1, sizeof (LIST)); t->data = str_dup (str); if (last) { last->next = t; @@ -382,7 +382,7 @@ static int add_to_spam_list (SPAM_LIST ** list, const char *pat, * the template, and leaving t pointed at the current item. */ t = last; - FREE(t->template); + mem_free(t->template); break; } if (!last->next) @@ -434,8 +434,8 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat) if (spam->rx && !str_cmp (spam->rx->pattern, pat)) { *list = spam->next; rx_free (&spam->rx); - FREE(&spam->template); - FREE(&spam); + mem_free(&spam->template); + mem_free(&spam); return 1; } @@ -444,8 +444,8 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat) if (!str_cmp (spam->rx->pattern, pat)) { prev->next = spam->next; rx_free (&spam->rx); - FREE(spam->template); - FREE(spam); + mem_free(spam->template); + mem_free(spam); spam = prev->next; ++nremoved; } @@ -468,12 +468,12 @@ static void remove_from_list (LIST ** l, const char *str) last = NULL; while (p) { if (ascii_strcasecmp (str, p->data) == 0) { - FREE (&p->data); + mem_free (&p->data); if (last) last->next = p->next; else (*l) = p->next; - FREE (&p); + mem_free (&p); } else { last = p; @@ -559,10 +559,10 @@ static int parse_ifdef (BUFFER * tmp, BUFFER * s, unsigned long data, if ((data && res) || (!data && !res)) { if (mutt_parse_rc_line (tmp->data, &token, err) == -1) { mutt_error ("Error: %s", err->data); - FREE (&token.data); + mem_free (&token.data); return (-1); } - FREE (&token.data); + mem_free (&token.data); } return 0; } @@ -680,10 +680,10 @@ static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data, /* Add to the spam list. */ if (add_to_spam_list (&SpamList, buf->data, templ.data, err) != 0) { - FREE (&templ.data); + mem_free (&templ.data); return -1; } - FREE (&templ.data); + mem_free (&templ.data); } /* If not, try to remove from the nospam list. */ @@ -873,7 +873,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data, if (!tmp) { /* create a new alias */ - tmp = (ALIAS *) safe_calloc (1, sizeof (ALIAS)); + tmp = (ALIAS *) mem_calloc (1, sizeof (ALIAS)); tmp->self = tmp; tmp->name = str_dup (buf->data); /* give the main addressbook code a chance */ @@ -977,7 +977,7 @@ static int parse_my_hdr (BUFFER * buf, BUFFER * s, unsigned long data, /* see if there is already a field by this name */ if (ascii_strncasecmp (buf->data, tmp->data, keylen) == 0) { /* replace the old value */ - FREE (&tmp->data); + mem_free (&tmp->data); tmp->data = buf->data; memset (buf, 0, sizeof (BUFFER)); return 0; @@ -1099,16 +1099,16 @@ static void mutt_restore_default (struct option_t *p) rx_t *pp = (rx_t *) p->data; int flags = 0; - FREE (&pp->pattern); + mem_free (&pp->pattern); if (pp->rx) { regfree (pp->rx); - FREE (&pp->rx); + mem_free (&pp->rx); } if (p->init) { char *s = (char *) p->init; - pp->rx = safe_calloc (1, sizeof (regex_t)); + pp->rx = mem_calloc (1, sizeof (regex_t)); if (str_cmp (p->option, "mask") != 0) flags |= mutt_which_case ((const char *) p->init); if (str_cmp (p->option, "mask") == 0 && *s == '!') { @@ -1119,9 +1119,9 @@ static void mutt_restore_default (struct option_t *p) fprintf (stderr, _("mutt_restore_default(%s): error in regexp: %s\n"), p->option, pp->pattern); - FREE (&pp->pattern); + mem_free (&pp->pattern); regfree (pp->rx); - FREE (&pp->rx); + mem_free (&pp->rx); } else str_replace (&pp->pattern, (char *) p->init); @@ -1242,7 +1242,7 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, if (DTYPE (MuttVars[idx].type) == DT_ADDR) rfc822_free_address ((ADDRESS **) MuttVars[idx].data); else - FREE ((void *) MuttVars[idx].data); + mem_free ((void *) MuttVars[idx].data); } else if (query || *s->dptr != '=') { char _tmp[STRING]; @@ -1269,7 +1269,7 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, if (DTYPE (MuttVars[idx].type) == DT_ADDR) rfc822_free_address ((ADDRESS **) MuttVars[idx].data); else - FREE ((void *) MuttVars[idx].data); + mem_free ((void *) MuttVars[idx].data); mutt_extract_token (tmp, s, 0); if (DTYPE (MuttVars[idx].type) == DT_PATH) { @@ -1328,19 +1328,19 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, } } - rx = (regex_t *) safe_malloc (sizeof (regex_t)); + rx = (regex_t *) mem_malloc (sizeof (regex_t)); if ((e = REGCOMP (rx, p, flags)) != 0) { regerror (e, rx, err->data, err->dsize); regfree (rx); - FREE (&rx); + mem_free (&rx); break; } /* get here only if everything went smootly */ if (ptr->pattern) { - FREE (&ptr->pattern); + mem_free (&ptr->pattern); regfree ((regex_t *) ptr->rx); - FREE (&ptr->rx); + mem_free (&ptr->rx); } ptr->pattern = str_dup (tmp->data); @@ -1584,7 +1584,7 @@ static int source_rc (const char *rcfile, BUFFER * err) mutt_error (_("Error in %s, line %d: %s"), rcfile, line, err->data); if (--rc < -MAXERRS) { if (conv) - FREE (¤tline); + mem_free (¤tline); break; } } @@ -1593,10 +1593,10 @@ static int source_rc (const char *rcfile, BUFFER * err) rc = -1; } if (conv) - FREE (¤tline); + mem_free (¤tline); } - FREE (&token.data); - FREE (&linebuf); + mem_free (&token.data); + mem_free (&linebuf); fclose (f); if (pid != -1) mutt_wait_filter (pid); @@ -1681,7 +1681,7 @@ int mutt_parse_rc_line ( /* const */ char *line, BUFFER * token, BUFFER * err) r = 0; finish: if (expn.destroy) - FREE (&expn.data); + mem_free (&expn.data); return (r); } @@ -2003,13 +2003,13 @@ int mutt_query_variables (LIST * queries) snprintf (command, sizeof (command), "set ?%s\n", p->data); if (mutt_parse_rc_line (command, &token, &err) == -1) { fprintf (stderr, "%s\n", err.data); - FREE (&token.data); + mem_free (&token.data); return 1; } printf ("%s\n", err.data); } - FREE (&token.data); + mem_free (&token.data); return 0; } @@ -2045,11 +2045,11 @@ static int mutt_execute_commands (LIST * p) for (; p; p = p->next) { if (mutt_parse_rc_line (p->data, &token, &err) != 0) { fprintf (stderr, _("Error in command line: %s\n"), err.data); - FREE (&token.data); + mem_free (&token.data); return (-1); } } - FREE (&token.data); + mem_free (&token.data); return 0; } @@ -2123,7 +2123,7 @@ void mutt_init (int skip_sys_rc, LIST * commands) else #endif /* DOMAIN */ if (*DOMAIN != '@') { - Fqdn = safe_malloc (str_len (DOMAIN) + str_len (Hostname) + 2); + Fqdn = mem_malloc (str_len (DOMAIN) + str_len (Hostname) + 2); sprintf (Fqdn, "%s.%s", NONULL (Hostname), DOMAIN); /* __SPRINTF_CHECKED__ */ } else @@ -2196,7 +2196,7 @@ void mutt_init (int skip_sys_rc, LIST * commands) memset (&token, 0, sizeof (token)); parse_my_hdr (&token, &buf, 0, &err); - FREE (&token.data); + mem_free (&token.data); } if ((p = getenv ("EMAIL")) != NULL) @@ -2264,11 +2264,11 @@ void mutt_init (int skip_sys_rc, LIST * commands) } else { strfcpy (buffer, Muttrc, sizeof (buffer)); - FREE (&Muttrc); + mem_free (&Muttrc); mutt_expand_path (buffer, sizeof (buffer)); Muttrc = str_dup (buffer); } - FREE (&AliasFile); + mem_free (&AliasFile); AliasFile = str_dup (NONULL (Muttrc)); /* Process the global rc file if it exists and the user hasn't explicity @@ -2327,7 +2327,7 @@ void mutt_init (int skip_sys_rc, LIST * commands) need_pause = 1; } /* this is not needed during runtime */ - FREE(&CurRCFile); + mem_free(&CurRCFile); if (need_pause && !option (OPTNOCURSES)) { if (mutt_any_key_to_continue (NULL) == -1) @@ -2384,14 +2384,14 @@ int mutt_dump_variables (void) { ((struct option_t*) tmp->data[i])->option); if (mutt_parse_rc_line (command, &token, &err) == -1) { fprintf (stderr, "%s\n", err.data); - FREE (&token.data); + mem_free (&token.data); list_del (&tmp, NULL); return 1; } printf("%s\n", err.data); } } - FREE (&token.data); + mem_free (&token.data); list_del (&tmp, NULL); return 0; } diff --git a/intl/dcigettext.c b/intl/dcigettext.c index 6acde19..2263c76 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -306,7 +306,7 @@ static const char *guess_category_value PARAMS ((int category, #ifdef HAVE_ALLOCA /* Nothing has to be done. */ # define ADD_BLOCK(list, address) /* nothing */ -# define FREE_BLOCKS(list) /* nothing */ +# define mem_free_BLOCKS(list) /* nothing */ #else struct block_list { @@ -324,7 +324,7 @@ struct block_list (list) = newp; \ } \ } while (0) -# define FREE_BLOCKS(list) \ +# define mem_free_BLOCKS(list) \ do { \ while (list != NULL) { \ struct block_list *old = list; \ @@ -517,7 +517,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) { /* We cannot get the current working directory. Don't signal an error but simply return the default string. */ - FREE_BLOCKS (block_list); + mem_free_BLOCKS (block_list); __libc_rwlock_unlock (_nl_state_lock); __set_errno (saved_errno); return (plural == 0 @@ -582,7 +582,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) if (strcmp (single_locale, "C") == 0 || strcmp (single_locale, "POSIX") == 0) { - FREE_BLOCKS (block_list); + mem_free_BLOCKS (block_list); __libc_rwlock_unlock (_nl_state_lock); __set_errno (saved_errno); return (plural == 0 @@ -621,7 +621,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) { /* Found the translation of MSGID1 in domain DOMAIN: starting at RETVAL, RETLEN bytes. */ - FREE_BLOCKS (block_list); + mem_free_BLOCKS (block_list); __set_errno (saved_errno); #if defined HAVE_TSEARCH || defined _LIBC if (foundp == NULL) diff --git a/intl/plural.c b/intl/plural.c index d30a8d6..6aa6d80 100644 --- a/intl/plural.c +++ b/intl/plural.c @@ -120,9 +120,9 @@ code is also used in GNU C Library where the names have a __ prefix. So we have to make a difference here. */ #ifdef _LIBC -# define FREE_EXPRESSION __gettext_free_exp +# define mem_free_EXPRESSION __gettext_free_exp #else -# define FREE_EXPRESSION gettext_free_exp__ +# define mem_free_EXPRESSION gettext_free_exp__ # define __gettextparse gettextparse__ #endif @@ -207,7 +207,7 @@ new_exp (nargs, op, args) fail: for (i = nargs - 1; i >= 0; i--) - FREE_EXPRESSION (args[i]); + mem_free_EXPRESSION (args[i]); return NULL; } @@ -283,14 +283,14 @@ new_exp_3 (op, bexp, tbranch, fbranch) # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# define YYSTACK_mem_free(Ptr) do { /* empty */; } while (0) # else # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free +# define YYSTACK_mem_free free # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ @@ -1023,7 +1023,7 @@ int yynerrs; # undef YYSTACK_RELOCATE if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + YYSTACK_mem_free (yyss1); } # endif #endif /* no yyoverflow */ @@ -1310,7 +1310,7 @@ yyerrlab: } } yyerror (yymsg); - YYSTACK_FREE (yymsg); + YYSTACK_mem_free (yymsg); } else yyerror ("syntax error; also virtual memory exhausted"); @@ -1424,7 +1424,7 @@ yyoverflowlab: yyreturn: #ifndef yyoverflow if (yyss != yyssa) - YYSTACK_FREE (yyss); + YYSTACK_mem_free (yyss); #endif return yyresult; } @@ -1435,7 +1435,7 @@ yyreturn: void internal_function -FREE_EXPRESSION (exp) +mem_free_EXPRESSION (exp) struct expression *exp; { if (exp == NULL) @@ -1445,13 +1445,13 @@ FREE_EXPRESSION (exp) switch (exp->nargs) { case 3: - FREE_EXPRESSION (exp->val.args[2]); + mem_free_EXPRESSION (exp->val.args[2]); /* FALLTHROUGH */ case 2: - FREE_EXPRESSION (exp->val.args[1]); + mem_free_EXPRESSION (exp->val.args[1]); /* FALLTHROUGH */ case 1: - FREE_EXPRESSION (exp->val.args[0]); + mem_free_EXPRESSION (exp->val.args[0]); /* FALLTHROUGH */ default: break; diff --git a/keymap.c b/keymap.c index 9db65e9..9b501f2 100644 --- a/keymap.c +++ b/keymap.c @@ -92,9 +92,9 @@ static struct keymap_t *allocKeys (int len, keycode_t * keys) { struct keymap_t *p; - p = safe_calloc (1, sizeof (struct keymap_t)); + p = mem_calloc (1, sizeof (struct keymap_t)); p->len = len; - p->keys = safe_malloc (len * sizeof (keycode_t)); + p->keys = mem_malloc (len * sizeof (keycode_t)); memcpy (p->keys, keys, len * sizeof (keycode_t)); return (p); } @@ -200,10 +200,10 @@ void km_bind (char *s, int menu, int op, char *macro, char *descr) do { len = tmp->eq; next = tmp->next; - FREE (&tmp->macro); - FREE (&tmp->keys); - FREE (&tmp->descr); - FREE (&tmp); + mem_free (&tmp->macro); + mem_free (&tmp->keys); + mem_free (&tmp->descr); + mem_free (&tmp); tmp = next; } while (tmp && len >= pos); @@ -707,7 +707,7 @@ static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus, strfcpy (err->data, _("too few arguments"), err->dsize); } error: - FREE (&buf.data); + mem_free (&buf.data); return (NULL); } @@ -807,7 +807,7 @@ int mutt_parse_bind (BUFFER * buf, BUFFER * s, unsigned long data, } } } - FREE (&key); + mem_free (&key); return (r); } @@ -845,7 +845,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, } } - FREE (&seq); + mem_free (&seq); } else { for (i = 0; i < nummenus; ++i) { @@ -854,7 +854,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, } } } - FREE (&key); + mem_free (&key); return (r); } diff --git a/lib.c b/lib.c index d9900aa..4f1fee3 100644 --- a/lib.c +++ b/lib.c @@ -397,13 +397,13 @@ char *mutt_read_line (char *s, size_t * size, FILE * fp, int *line) char *ch; if (!s) { - s = safe_malloc (STRING); + s = mem_malloc (STRING); *size = STRING; } FOREVER { if (fgets (s + offset, *size - offset, fp) == NULL) { - FREE (&s); + mem_free (&s); return NULL; } if ((ch = strchr (s + offset, '\n')) != NULL) { @@ -433,7 +433,7 @@ char *mutt_read_line (char *s, size_t * size, FILE * fp, int *line) /* There wasn't room for the line -- increase ``s'' */ offset = *size - 1; /* overwrite the terminating 0 */ *size += STRING; - safe_realloc (&s, *size); + mem_realloc (&s, *size); } } } diff --git a/lib/list.c b/lib/list.c index e921b20..a454c8f 100644 --- a/lib/list.c +++ b/lib/list.c @@ -15,7 +15,7 @@ #include "mem.h" list2_t* list_new (void) { - return (safe_calloc (1, sizeof (list2_t))); + return (mem_calloc (1, sizeof (list2_t))); } void list_del (list2_t** l, list_del_t* del) { @@ -25,21 +25,21 @@ void list_del (list2_t** l, list_del_t* del) { if (del) for (i = 0; i < (*l)->length; i++) del (&(*l)->data[i]); - FREE(&(*l)->data); - FREE(l); + mem_free(&(*l)->data); + mem_free(l); } void list_push_back (list2_t** l, void* p) { if (!*l) *l = list_new (); - safe_realloc (&(*l)->data, (++(*l)->length)*sizeof(void*)); + mem_realloc (&(*l)->data, (++(*l)->length)*sizeof(void*)); (*l)->data[(*l)->length-1] = p; } void list_push_front (list2_t** l, void* p) { if (!*l) *l = list_new (); - safe_realloc (&(*l)->data, (++(*l)->length)*sizeof(void*)); + mem_realloc (&(*l)->data, (++(*l)->length)*sizeof(void*)); if ((*l)->length > 1) memmove (&(*l)->data[1], &(*l)->data[0], ((*l)->length-1)*sizeof(void*)); (*l)->data[0] = p; @@ -50,7 +50,7 @@ void* list_pop_back (list2_t* l) { if (list_empty(l)) return (NULL); p = l->data[l->length-1]; - safe_realloc (&l->data, --(l->length)*sizeof(void*)); + mem_realloc (&l->data, --(l->length)*sizeof(void*)); return (p); } @@ -60,7 +60,7 @@ void* list_pop_front (list2_t* l) { return (NULL); p = l->data[0]; memmove (&l->data[0], &l->data[1], (--(l->length))*sizeof(void*)); - safe_realloc (&l->data, l->length*sizeof(void*)); + mem_realloc (&l->data, l->length*sizeof(void*)); return (p); } @@ -72,7 +72,7 @@ void* list_pop_idx (list2_t* l, int c) { return (list_pop_back (l)); p = l->data[c]; memmove (&l->data[c], &l->data[c+1], (l->length-c)*sizeof(void*)); - safe_realloc (&l->data, (--(l->length))*sizeof(void*)); + mem_realloc (&l->data, (--(l->length))*sizeof(void*)); return (p); } @@ -82,7 +82,7 @@ list2_t* list_cpy (list2_t* l) { return (NULL); ret = list_new (); ret->length = l->length; - ret->data = safe_malloc (l->length*sizeof(void*)); + ret->data = mem_malloc (l->length*sizeof(void*)); memcpy (ret->data, l->data, l->length*sizeof(void*)); return (ret); } @@ -94,7 +94,7 @@ list2_t* list_dup (list2_t* l, void* (*dup) (void*)) { return (NULL); ret = list_new (); ret->length = l->length; - ret->data = safe_malloc (l->length*sizeof(void*)); + ret->data = mem_malloc (l->length*sizeof(void*)); for (i = 0; i < l->length; i++) ret->data[i] = dup (l->data[i]); return (ret); diff --git a/lib/mem.c b/lib/mem.c index f978090..344b7cf 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -10,38 +10,38 @@ #include "exit.h" #include "intl.h" -void *_safe_calloc (size_t nmemb, size_t size, int line, const char* fname) { +void *_mem_calloc (size_t nmemb, size_t size, int line, const char* fname) { void *p; if (!nmemb || !size) return NULL; if (((size_t) - 1) / nmemb <= size) { - exit_fatal ("safe_calloc", _("Integer overflow -- can't allocate memory!"), + exit_fatal ("mem_calloc", _("Integer overflow -- can't allocate memory!"), line, fname, 1); return (NULL); } if (!(p = calloc (nmemb, size))) { - exit_fatal ("safe_calloc", _("Out of memory!"), line, fname, 1); + exit_fatal ("mem_calloc", _("Out of memory!"), line, fname, 1); return (NULL); } return p; } -void *_safe_malloc (size_t siz, int line, const char* fname) { +void *_mem_malloc (size_t siz, int line, const char* fname) { void *p; if (siz == 0) return 0; if ((p = (void *) malloc (siz)) == 0) { /* __MEM_CHECKED__ */ - exit_fatal ("safe_malloc", _("Out of memory!"), line, fname, 1); + exit_fatal ("mem_malloc", _("Out of memory!"), line, fname, 1); return (NULL); } return (p); } -void _safe_realloc (void *ptr, size_t siz, int line, const char* fname) { +void _mem_realloc (void *ptr, size_t siz, int line, const char* fname) { void *r; void **p = (void **) ptr; @@ -61,12 +61,12 @@ void _safe_realloc (void *ptr, size_t siz, int line, const char* fname) { } if (!r) - exit_fatal ("safe_realloc", _("Out of memory!"), line, fname, 1); + exit_fatal ("mem_realloc", _("Out of memory!"), line, fname, 1); *p = r; } -void _safe_free (void *ptr) { +void _mem_free (void *ptr) { void **p = (void **) ptr; if (*p) { diff --git a/lib/mem.h b/lib/mem.h index 1afac35..251444e 100644 --- a/lib/mem.h +++ b/lib/mem.h @@ -3,20 +3,19 @@ * It's licensed under the GNU General Public License, * please see the file GPL in the top level source directory. */ - #ifndef _LIB_MEM_H #define _LIB_MEM_H #include -void* _safe_malloc (size_t, int, const char*); -void* _safe_calloc (size_t, size_t, int, const char*); -void _safe_realloc (void*, size_t, int, const char*); -void _safe_free (void*); +void* _mem_malloc (size_t, int, const char*); +void* _mem_calloc (size_t, size_t, int, const char*); +void _mem_realloc (void*, size_t, int, const char*); +void _mem_free (void*); -#define safe_malloc(s) _safe_malloc(s,__LINE__,__FILE__) -#define safe_calloc(s,c) _safe_calloc(s,c,__LINE__,__FILE__) -#define safe_realloc(p,c) _safe_realloc(p,c,__LINE__,__FILE__) -#define FREE(x) _safe_free(x) +#define mem_malloc(s) _mem_malloc(s,__LINE__,__FILE__) +#define mem_calloc(s,c) _mem_calloc(s,c,__LINE__,__FILE__) +#define mem_realloc(p,c) _mem_realloc(p,c,__LINE__,__FILE__) +#define mem_free(x) _mem_free(x) #endif /* !_LIB_MEM_H */ diff --git a/lib/rx.c b/lib/rx.c index e7c4f3c..c0f6982 100644 --- a/lib/rx.c +++ b/lib/rx.c @@ -14,10 +14,10 @@ #include "str.h" rx_t *rx_compile (const char *s, int flags) { - rx_t *pp = safe_calloc (1, sizeof (rx_t)); + rx_t *pp = mem_calloc (1, sizeof (rx_t)); pp->pattern = str_dup (s); - pp->rx = safe_calloc (1, sizeof (regex_t)); + pp->rx = mem_calloc (1, sizeof (regex_t)); if (REGCOMP(pp->rx, NONULL (s), flags) != 0) rx_free (&pp); @@ -25,10 +25,10 @@ rx_t *rx_compile (const char *s, int flags) { } void rx_free (rx_t** p) { - FREE(&(*p)->pattern); + mem_free(&(*p)->pattern); regfree ((*p)->rx); - FREE(&(*p)->rx); - FREE(p); + mem_free(&(*p)->rx); + mem_free(p); } int rx_compare (const rx_t* r1, const rx_t* r2) { diff --git a/lib/str.c b/lib/str.c index 76eb248..f70bfda 100644 --- a/lib/str.c +++ b/lib/str.c @@ -24,7 +24,7 @@ char *str_dup (const char *s) if (!s || !*s) return 0; l = str_len (s) + 1; - p = (char *) safe_malloc (l); + p = (char *) mem_malloc (l); memcpy (p, s, l); return (p); } @@ -99,7 +99,7 @@ int str_coll (const char *a, const char *b) void str_replace (char **p, const char *s) { - FREE (p); + mem_free (p); *p = str_dup (s); } @@ -107,7 +107,7 @@ void str_adjust (char **p) { if (!p || !*p) return; - safe_realloc (p, str_len (*p) + 1); + mem_realloc (p, str_len (*p) + 1); } /* convert all characters in the string to lowercase */ @@ -148,7 +148,7 @@ char *str_substrdup (const char *begin, const char *end) else len = str_len (begin); - p = safe_malloc (len + 1); + p = mem_malloc (len + 1); memcpy (p, begin, len); p[len] = 0; return p; diff --git a/main.c b/main.c index 8d4867b..69ecf02 100644 --- a/main.c +++ b/main.c @@ -841,7 +841,7 @@ int main (int argc, char **argv) mutt_endwin (NULL); perror (tempfile); fclose (fin); - FREE (&tempfile); + mem_free (&tempfile); exit (1); } if (fin) @@ -854,7 +854,7 @@ int main (int argc, char **argv) } } - FREE (&bodytext); + mem_free (&bodytext); if (attach) { LIST *t = attach; @@ -956,7 +956,7 @@ int main (int argc, char **argv) if (option (OPTXTERMSETTITLES)) mutt_xterm_set_title (NONULL (XtermLeave)); if (Context) - FREE (&Context); + mem_free (&Context); } mutt_endwin (Errorbuf); } diff --git a/mbox.c b/mbox.c index 7309d07..75cc3cc 100644 --- a/mbox.c +++ b/mbox.c @@ -643,8 +643,8 @@ static int _mbox_sync_mailbox (CONTEXT * ctx, int unused, int *index_hint) offset -= (sizeof MMDF_SEP - 1); /* allocate space for the new offsets */ - newOffset = safe_calloc (ctx->msgcount - first, sizeof (struct m_update_t)); - oldOffset = safe_calloc (ctx->msgcount - first, sizeof (struct m_update_t)); + newOffset = mem_calloc (ctx->msgcount - first, sizeof (struct m_update_t)); + oldOffset = mem_calloc (ctx->msgcount - first, sizeof (struct m_update_t)); for (i = first, j = 0; i < ctx->msgcount; i++) { /* @@ -823,8 +823,8 @@ static int _mbox_sync_mailbox (CONTEXT * ctx, int unused, int *index_hint) ctx->hdrs[i]->index = j++; } } - FREE (&newOffset); - FREE (&oldOffset); + mem_free (&newOffset); + mem_free (&oldOffset); unlink (tempfile); /* remove partial copy of the mailbox */ mutt_unblock_signals (); @@ -849,8 +849,8 @@ bail: /* Come here in case of disaster */ mbox_unlock_mailbox (ctx); mutt_unblock_signals (); - FREE (&newOffset); - FREE (&oldOffset); + mem_free (&newOffset); + mem_free (&oldOffset); if ((ctx->fp = freopen (ctx->path, "r", ctx->fp)) == NULL) { mutt_error _("Could not reopen mailbox!"); @@ -929,11 +929,11 @@ static int mbox_reopen_mailbox (CONTEXT * ctx, int *index_hint) if (ctx->subj_hash) hash_destroy (&ctx->subj_hash, NULL); mutt_clear_threads (ctx); - FREE (&ctx->v2r); + mem_free (&ctx->v2r); if (ctx->readonly) { for (i = 0; i < ctx->msgcount; i++) mutt_free_header (&(ctx->hdrs[i])); /* nothing to do! */ - FREE (&ctx->hdrs); + mem_free (&ctx->hdrs); } else { /* save the old headers */ @@ -979,7 +979,7 @@ static int mbox_reopen_mailbox (CONTEXT * ctx, int *index_hint) /* free the old headers */ for (j = 0; j < old_msgcount; j++) mutt_free_header (&(old_hdrs[j])); - FREE (&old_hdrs); + mem_free (&old_hdrs); ctx->quiet = 0; return (-1); @@ -1047,7 +1047,7 @@ static int mbox_reopen_mailbox (CONTEXT * ctx, int *index_hint) msg_mod = 1; } } - FREE (&old_hdrs); + mem_free (&old_hdrs); } ctx->quiet = 0; @@ -1137,7 +1137,7 @@ static int mmdf_commit_message (MESSAGE* msg, CONTEXT* ctx) { } static mx_t* reg_mx (void) { - mx_t* fmt = safe_calloc (1, sizeof (mx_t)); + mx_t* fmt = mem_calloc (1, sizeof (mx_t)); fmt->local = 1; fmt->mx_check_empty = mbox_check_empty; fmt->mx_is_magic = mbox_is_magic; diff --git a/menu.c b/menu.c index 08e1fb2..c24a248 100644 --- a/menu.c +++ b/menu.c @@ -149,7 +149,7 @@ void menu_pad_string (char *s, size_t n) { int shift = option (OPTARROWCURSOR) ? 3 : 0; int cols; - char *tmpbuf = safe_malloc (n); + char *tmpbuf = mem_malloc (n); if (option (OPTMBOXPANE)) cols = COLS - shift - SidebarWidth; @@ -158,7 +158,7 @@ void menu_pad_string (char *s, size_t n) mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, str_len (s), 1); tmpbuf[n - 1] = 0; snprintf (s, n, "%s", tmpbuf); /* overkill */ - FREE (&tmpbuf); + mem_free (&tmpbuf); } void menu_redraw_full (MUTTMENU * menu) @@ -656,7 +656,7 @@ static int menu_search_generic (MUTTMENU * m, regex_t * re, int n) MUTTMENU *mutt_new_menu (void) { - MUTTMENU *p = (MUTTMENU *) safe_calloc (1, sizeof (MUTTMENU)); + MUTTMENU *p = (MUTTMENU *) mem_calloc (1, sizeof (MUTTMENU)); p->current = 0; p->top = 0; @@ -672,16 +672,16 @@ void mutt_menuDestroy (MUTTMENU ** p) { int i; - FREE (&(*p)->searchBuf); + mem_free (&(*p)->searchBuf); if ((*p)->dialog) { for (i = 0; i < (*p)->max; i++) - FREE (&(*p)->dialog[i]); + mem_free (&(*p)->dialog[i]); - FREE (&(*p)->dialog); + mem_free (&(*p)->dialog); } - FREE (p); + mem_free (p); } #define M_SEARCH_UP 1 diff --git a/mh.c b/mh.c index 73a5638..c062eb9 100644 --- a/mh.c +++ b/mh.c @@ -81,7 +81,7 @@ static void mhs_alloc (struct mh_sequences *mhs, int i) if (i > mhs->max || !mhs->flags) { newmax = i + 128; - safe_realloc (&mhs->flags, sizeof (mhs->flags[0]) * (newmax + 1)); + mem_realloc (&mhs->flags, sizeof (mhs->flags[0]) * (newmax + 1)); for (j = mhs->max + 1; j <= newmax; j++) mhs->flags[j] = 0; @@ -91,7 +91,7 @@ static void mhs_alloc (struct mh_sequences *mhs, int i) static void mhs_free_sequences (struct mh_sequences *mhs) { - FREE (&mhs->flags); + mem_free (&mhs->flags); } static short mhs_check (struct mh_sequences *mhs, int i) @@ -173,7 +173,7 @@ static void mh_read_sequences (struct mh_sequences *mhs, const char *path) } } - FREE (&buff); + mem_free (&buff); safe_fclose (&fp); } @@ -214,7 +214,7 @@ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) } if ((*fp = fdopen (fd, "w")) == NULL) { - FREE (tgt); + mem_free (tgt); close (fd); unlink (path); return (-1); @@ -362,7 +362,7 @@ void mh_update_sequences (CONTEXT * ctx) unlink (tmpfname); } - FREE (&tmpfname); + mem_free (&tmpfname); } static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen, @@ -414,7 +414,7 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen, } } safe_fclose (&ofp); - FREE (&buff); + mem_free (&buff); if (!unseen_done && unseen) fprintf (nfp, "%s: %d\n", NONULL (MhUnseen), n); @@ -429,7 +429,7 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen, if (safe_rename (tmpfname, sequences) != 0) unlink (tmpfname); - FREE (&tmpfname); + mem_free (&tmpfname); } static void mh_update_maildir (struct maildir *md, struct mh_sequences *mhs) @@ -460,11 +460,11 @@ static void maildir_free_entry (struct maildir **md) if (!md || !*md) return; - FREE (&(*md)->canon_fname); + mem_free (&(*md)->canon_fname); if ((*md)->h) mutt_free_header (&(*md)->h); - FREE (md); + mem_free (md); } static void maildir_free_maildir (struct maildir **md) @@ -525,7 +525,7 @@ static void maildir_parse_flags (HEADER * h, const char *path) } if (q == h->maildir_flags) - FREE (&h->maildir_flags); + mem_free (&h->maildir_flags); else if (q) *q = '\0'; } @@ -642,7 +642,7 @@ static int maildir_parse_entry (CONTEXT * ctx, struct maildir ***last, else h->path = str_dup (fname); - entry = safe_calloc (sizeof (struct maildir), 1); + entry = mem_calloc (sizeof (struct maildir), 1); entry->h = h; entry->header_parsed = (ctx->magic == M_MH); #ifdef USE_INODESORT @@ -897,7 +897,7 @@ void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md) else mutt_free_header (&p->h); #if USE_HCACHE - FREE (&data); + mem_free (&data); #endif } #if USE_HCACHE @@ -1061,7 +1061,7 @@ static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr } if ((msg->fp = fdopen (fd, "w")) == NULL) { - FREE (&msg->path); + mem_free (&msg->path); close (fd); unlink (path); return (-1); @@ -1126,7 +1126,7 @@ static int maildir_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr) if (safe_rename (msg->path, full) == 0) { if (hdr) str_replace (&hdr->path, path); - FREE (&msg->path); + mem_free (&msg->path); /* * Adjust the mtime on the file to match the time at which this @@ -1212,7 +1212,7 @@ static int _mh_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr, if (safe_rename (msg->path, path) == 0) { if (hdr) str_replace (&hdr->path, tmp); - FREE (&msg->path); + mem_free (&msg->path); break; } else if (errno != EEXIST) { @@ -1713,7 +1713,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint, int unused) safe_fclose (&fp); if (safe_rename (tmp, buf) == -1) unlink (tmp); - FREE (&tmp); + mem_free (&tmp); } } @@ -1969,7 +1969,7 @@ static int maildir_is_magic (const char* path, struct stat* st) { /* routines common to maildir and mh */ static mx_t* reg_mx (void) { - mx_t* fmt = safe_calloc (1, sizeof (mx_t)); + mx_t* fmt = mem_calloc (1, sizeof (mx_t)); fmt->local = 1; fmt->mx_access = access; fmt->mx_sync_mailbox = mh_sync_mailbox; diff --git a/mutt.h b/mutt.h index 3e712dc..d2dcd8b 100644 --- a/mutt.h +++ b/mutt.h @@ -571,8 +571,8 @@ typedef struct spam_list_t { } SPAM_LIST; -#define mutt_new_list() safe_calloc (1, sizeof (LIST)) -#define mutt_new_spam_list() safe_calloc (1, sizeof (SPAM_LIST)) +#define mutt_new_list() mem_calloc (1, sizeof (LIST)) +#define mutt_new_spam_list() mem_calloc (1, sizeof (SPAM_LIST)) void mutt_free_list (LIST **); void mutt_free_spam_list (SPAM_LIST **); LIST *mutt_copy_list (LIST *); diff --git a/mutt_idna.c b/mutt_idna.c index 4b42e32..82796c8 100644 --- a/mutt_idna.c +++ b/mutt_idna.c @@ -73,8 +73,8 @@ int mutt_idna_to_local (const char *in, char **out, int flags) irrev = 1; } - FREE (&t2); - FREE (&tmp); + mem_free (&t2); + mem_free (&tmp); if (irrev) goto notrans; @@ -83,7 +83,7 @@ int mutt_idna_to_local (const char *in, char **out, int flags) return 0; notrans: - FREE (out); + mem_free (out); *out = str_dup (in); return 1; } @@ -105,9 +105,9 @@ int mutt_local_to_idna (const char *in, char **out) if (!rv && idna_to_ascii_8z (tmp, out, 1) != IDNA_SUCCESS) rv = -2; - FREE (&tmp); + mem_free (&tmp); if (rv < 0) { - FREE (out); + mem_free (out); *out = str_dup (in); } return rv; @@ -128,7 +128,7 @@ static int mbox_to_udomain (const char *mbx, char **user, char **domain) p = strchr (mbx, '@'); if (!p) return -1; - *user = safe_calloc ((p - mbx + 1), sizeof (mbx[0])); + *user = mem_calloc ((p - mbx + 1), sizeof (mbx[0])); strfcpy (*user, mbx, (p - mbx + 1)); *domain = str_dup (p + 1); return 0; @@ -155,13 +155,13 @@ int mutt_addrlist_to_idna (ADDRESS * a, char **err) *err = str_dup (domain); } else { - safe_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2); + mem_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2); sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */ } - FREE (&domain); - FREE (&user); - FREE (&tmp); + mem_free (&domain); + mem_free (&user); + mem_free (&tmp); if (e) return -1; @@ -182,13 +182,13 @@ int mutt_addrlist_to_local (ADDRESS * a) continue; if (mutt_idna_to_local (domain, &tmp, 0) == 0) { - safe_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2); + mem_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2); sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */ } - FREE (&domain); - FREE (&user); - FREE (&tmp); + mem_free (&domain); + mem_free (&user); + mem_free (&tmp); } return 0; @@ -205,22 +205,22 @@ const char *mutt_addr_for_display (ADDRESS * a) char *domain = NULL; char *user = NULL; - FREE (&buff); + mem_free (&buff); if (mbox_to_udomain (a->mailbox, &user, &domain) != 0) return a->mailbox; if (mutt_idna_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0) { - FREE (&user); - FREE (&domain); - FREE (&tmp); + mem_free (&user); + mem_free (&domain); + mem_free (&tmp); return a->mailbox; } - safe_realloc (&buff, str_len (tmp) + str_len (user) + 2); + mem_realloc (&buff, str_len (tmp) + str_len (user) + 2); sprintf (buff, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */ - FREE (&tmp); - FREE (&user); - FREE (&domain); + mem_free (&tmp); + mem_free (&user); + mem_free (&domain); return buff; } diff --git a/mutt_libesmtp.c b/mutt_libesmtp.c index f29546f..93bfd96 100644 --- a/mutt_libesmtp.c +++ b/mutt_libesmtp.c @@ -188,7 +188,7 @@ int mutt_invoke_libesmtp (ADDRESS * from, /* the sender */ /* Create hostname:port string and tell libesmtp */ /* len = SmtpHost len + colon + max port (65536 => 5 chars) + terminator */ hostportlen = str_len (SmtpHost) + 7; - hostportstr = safe_malloc (hostportlen); + hostportstr = mem_malloc (hostportlen); snprintf (hostportstr, hostportlen, "%s:%d", SmtpHost, SmtpPort); if (!smtp_set_server (session, hostportstr)) SMTPFAIL ("smtp_set_server"); diff --git a/mutt_sasl.c b/mutt_sasl.c index 017d691..095a9ae 100644 --- a/mutt_sasl.c +++ b/mutt_sasl.c @@ -364,7 +364,7 @@ int mutt_sasl_interact (sasl_interact_t * interaction) return SASL_FAIL; interaction->len = str_len (resp) + 1; - interaction->result = safe_malloc (interaction->len); + interaction->result = mem_malloc (interaction->len); memcpy ((char*) interaction->result, resp, interaction->len); interaction++; @@ -391,7 +391,7 @@ int mutt_sasl_interact (sasl_interact_t * interaction) * for the read/write methods. */ void mutt_sasl_setup_conn (CONNECTION * conn, sasl_conn_t * saslconn) { - SASL_DATA *sasldata = (SASL_DATA *) safe_malloc (sizeof (SASL_DATA)); + SASL_DATA *sasldata = (SASL_DATA *) mem_malloc (sizeof (SASL_DATA)); sasldata->saslconn = saslconn; /* get ssf so we know whether we have to (en|de)code read/write */ @@ -489,7 +489,7 @@ static int mutt_sasl_cb_pass (sasl_conn_t * conn, void *context, int id, len = str_len (account->pass); - *psecret = (sasl_secret_t *) safe_malloc (sizeof (sasl_secret_t) + len); + *psecret = (sasl_secret_t *) mem_malloc (sizeof (sasl_secret_t) + len); (*psecret)->len = len; strcpy ((char*) (*psecret)->data, account->pass); /* __STRCPY_CHECKED__ */ @@ -532,9 +532,9 @@ static int mutt_sasl_conn_close (CONNECTION * conn) /* release sasl resources */ sasl_dispose (&sasldata->saslconn); #ifndef USE_SASL2 - FREE (&sasldata->buf); + mem_free (&sasldata->buf); #endif - FREE (&sasldata); + mem_free (&sasldata); /* call underlying close */ rc = (conn->conn_close) (conn); @@ -565,7 +565,7 @@ static int mutt_sasl_conn_read (CONNECTION * conn, char *buf, size_t len) conn->sockdata = sasldata->sockdata; #ifndef USE_SASL2 - FREE (&sasldata->buf); + mem_free (&sasldata->buf); #endif sasldata->bpos = 0; sasldata->blen = 0; @@ -636,7 +636,7 @@ static int mutt_sasl_conn_write (CONNECTION * conn, const char *buf, rc = (sasldata->msasl_write) (conn, pbuf, plen); #ifndef USE_SASL2 - FREE (&pbuf); + mem_free (&pbuf); #endif if (rc != plen) goto fail; diff --git a/mutt_socket.c b/mutt_socket.c index 6cccc7a..869917d 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -189,7 +189,7 @@ void mutt_socket_free (CONNECTION * conn) /* head is special case, doesn't need prev updated */ if (iter == conn) { Connections = iter->next; - FREE (&iter); + mem_free (&iter); return; } @@ -197,7 +197,7 @@ void mutt_socket_free (CONNECTION * conn) if (iter->next == conn) { tmp = iter->next; iter->next = tmp->next; - FREE (&tmp); + mem_free (&tmp); return; } iter = iter->next; @@ -326,7 +326,7 @@ static CONNECTION *socket_new_conn (void) { CONNECTION *conn; - conn = (CONNECTION *) safe_calloc (1, sizeof (CONNECTION)); + conn = (CONNECTION *) mem_calloc (1, sizeof (CONNECTION)); conn->fd = -1; return conn; @@ -406,7 +406,7 @@ int raw_socket_open (CONNECTION * conn) rc = getaddrinfo (host_idna, port, &hints, &res); # ifdef HAVE_LIBIDN - FREE (&host_idna); + mem_free (&host_idna); # endif if (rc) { @@ -456,7 +456,7 @@ int raw_socket_open (CONNECTION * conn) if ((he = gethostbyname (host_idna)) == NULL) { # ifdef HAVE_LIBIDN - FREE (&host_idna); + mem_free (&host_idna); # endif mutt_error (_("Could not find the host \"%s\""), conn->account.host); @@ -464,7 +464,7 @@ int raw_socket_open (CONNECTION * conn) } # ifdef HAVE_LIBIDN - FREE (&host_idna); + mem_free (&host_idna); # endif mutt_message (_("Connecting to %s..."), conn->account.host); diff --git a/mutt_ssl.c b/mutt_ssl.c index 870ab89..88bd825 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -84,7 +84,7 @@ int mutt_ssl_starttls (CONNECTION * conn) if (ssl_init ()) goto bail; - ssldata = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata)); + ssldata = (sslsockdata *) mem_calloc (1, sizeof (sslsockdata)); /* the ssl_use_xxx protocol options don't apply. We must use TLS in TLS. */ if (!(ssldata->ctx = SSL_CTX_new (TLSv1_client_method ()))) { debug_print (1, ("Error allocating SSL_CTX\n")); @@ -118,11 +118,11 @@ int mutt_ssl_starttls (CONNECTION * conn) return 0; bail_ssl: - FREE (&ssldata->ssl); + mem_free (&ssldata->ssl); bail_ctx: - FREE (&ssldata->ctx); + mem_free (&ssldata->ctx); bail_ssldata: - FREE (&ssldata); + mem_free (&ssldata); bail: return -1; } @@ -256,7 +256,7 @@ static int ssl_socket_open (CONNECTION * conn) if (raw_socket_open (conn) < 0) return -1; - data = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata)); + data = (sslsockdata *) mem_calloc (1, sizeof (sslsockdata)); conn->sockdata = data; data->ctx = SSL_CTX_new (SSLv23_client_method ()); @@ -348,7 +348,7 @@ static int ssl_socket_close (CONNECTION * conn) #endif SSL_free (data->ssl); SSL_CTX_free (data->ctx); - FREE (&conn->sockdata); + mem_free (&conn->sockdata); } return raw_socket_close (conn); @@ -582,9 +582,9 @@ static int ssl_check_certificate (sslsockdata * data) /* interactive check from user */ menu = mutt_new_menu (); menu->max = 19; - menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *)); + menu->dialog = (char **) mem_calloc (1, menu->max * sizeof (char *)); for (i = 0; i < menu->max; i++) - menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char)); + menu->dialog[i] = (char *) mem_calloc (1, SHORT_STRING * sizeof (char)); row = 0; strfcpy (menu->dialog[row], _("This certificate belongs to:"), diff --git a/mutt_ssl_gnutls.c b/mutt_ssl_gnutls.c index 8f6bd23..932370c 100644 --- a/mutt_ssl_gnutls.c +++ b/mutt_ssl_gnutls.c @@ -155,11 +155,11 @@ static int tls_negotiate (CONNECTION * conn) tlssockdata *data; int err; - data = (tlssockdata *) safe_calloc (1, sizeof (tlssockdata)); + data = (tlssockdata *) mem_calloc (1, sizeof (tlssockdata)); conn->sockdata = data; err = gnutls_certificate_allocate_credentials (&data->xcred); if (err < 0) { - FREE (&conn->sockdata); + mem_free (&conn->sockdata); mutt_error (_("gnutls_certificate_allocate_credentials: %s"), gnutls_strerror (err)); mutt_sleep (2); @@ -256,7 +256,7 @@ static int tls_negotiate (CONNECTION * conn) fail: gnutls_certificate_free_credentials (data->xcred); gnutls_deinit (data->state); - FREE (&conn->sockdata); + mem_free (&conn->sockdata); return -1; } @@ -269,7 +269,7 @@ static int tls_socket_close (CONNECTION * conn) gnutls_certificate_free_credentials (data->xcred); gnutls_deinit (data->state); - FREE(&conn->sockdata); + mem_free(&conn->sockdata); } return raw_socket_close (conn); @@ -304,7 +304,7 @@ static int tls_compare_certificates (const gnutls_datum * peercert) return 0; b64_data.size = filestat.st_size + 1; - b64_data_data = (unsigned char *) safe_calloc (1, b64_data.size); + b64_data_data = (unsigned char *) mem_calloc (1, b64_data.size); b64_data_data[b64_data.size - 1] = '\0'; b64_data.data = b64_data_data; @@ -319,7 +319,7 @@ static int tls_compare_certificates (const gnutls_datum * peercert) do { ret = gnutls_pem_base64_decode_alloc (NULL, &b64_data, &cert); if (ret != 0) { - FREE (&b64_data_data); + mem_free (&b64_data_data); return 0; } @@ -333,7 +333,7 @@ static int tls_compare_certificates (const gnutls_datum * peercert) if (memcmp (cert.data, peercert->data, cert.size) == 0) { /* match found */ gnutls_free (cert.data); - FREE (&b64_data_data); + mem_free (&b64_data_data); return 1; } } @@ -342,7 +342,7 @@ static int tls_compare_certificates (const gnutls_datum * peercert) } while (ptr != NULL); /* no match found */ - FREE (&b64_data_data); + mem_free (&b64_data_data); return 0; } @@ -415,7 +415,7 @@ static int tls_check_stored_hostname (const gnutls_datum * cert, if (str_cmp (linestr + pmatch[1].rm_so, hostname) == 0 && str_cmp (linestr + pmatch[2].rm_so, buf) == 0) { regfree (&preg); - FREE(&linestr); + mem_free(&linestr); fclose (fp); return 1; } @@ -583,9 +583,9 @@ static int tls_check_certificate (CONNECTION * conn) /* interactive check from user */ menu = mutt_new_menu (); menu->max = 25; - menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *)); + menu->dialog = (char **) mem_calloc (1, menu->max * sizeof (char *)); for (i = 0; i < menu->max; i++) - menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char)); + menu->dialog[i] = (char *) mem_calloc (1, SHORT_STRING * sizeof (char)); row = 0; strfcpy (menu->dialog[row], _("This certificate belongs to:"), diff --git a/mutt_tunnel.c b/mutt_tunnel.c index db5f50e..34a5789 100644 --- a/mutt_tunnel.c +++ b/mutt_tunnel.c @@ -59,7 +59,7 @@ static int tunnel_socket_open (CONNECTION * conn) int rc; int pin[2], pout[2]; - tunnel = (TUNNEL_DATA *) safe_malloc (sizeof (TUNNEL_DATA)); + tunnel = (TUNNEL_DATA *) mem_malloc (sizeof (TUNNEL_DATA)); conn->sockdata = tunnel; mutt_message (_("Connecting with \"%s\"..."), Tunnel); @@ -129,7 +129,7 @@ static int tunnel_socket_close (CONNECTION * conn) NONULL(mutt_strsysexit(WEXITSTATUS(status)))); mutt_sleep (2); } - FREE (&conn->sockdata); + mem_free (&conn->sockdata); return 0; } diff --git a/muttlib.c b/muttlib.c index f7633e1..00886ad 100644 --- a/muttlib.c +++ b/muttlib.c @@ -46,7 +46,7 @@ BODY *mutt_new_body (void) { - BODY *p = (BODY *) safe_calloc (1, sizeof (BODY)); + BODY *p = (BODY *) mem_calloc (1, sizeof (BODY)); p->disposition = DISPATTACH; p->use_disp = 1; @@ -177,12 +177,12 @@ void mutt_free_body (BODY ** p) else if (b->filename) debug_print (1, ("not unlinking %s.\n", b->filename)); - FREE (&b->filename); - FREE (&b->content); - FREE (&b->xtype); - FREE (&b->subtype); - FREE (&b->description); - FREE (&b->form_name); + mem_free (&b->filename); + mem_free (&b->content); + mem_free (&b->xtype); + mem_free (&b->subtype); + mem_free (&b->description); + mem_free (&b->form_name); if (b->hdr) { /* Don't free twice (b->hdr->content = b->parts) */ @@ -193,7 +193,7 @@ void mutt_free_body (BODY ** p) if (b->parts) mutt_free_body (&b->parts); - FREE (&b); + mem_free (&b); } *p = 0; @@ -205,11 +205,11 @@ void mutt_free_parameter (PARAMETER ** p) PARAMETER *o; while (t) { - FREE (&t->attribute); - FREE (&t->value); + mem_free (&t->attribute); + mem_free (&t->value); o = t; t = t->next; - FREE (&o); + mem_free (&o); } *p = 0; } @@ -225,12 +225,12 @@ LIST *mutt_add_list_n (LIST *head, const void *data, size_t len) { for (tmp = head; tmp && tmp->next; tmp = tmp->next); if (tmp) { - tmp->next = safe_malloc (sizeof (LIST)); + tmp->next = mem_malloc (sizeof (LIST)); tmp = tmp->next; } else - head = tmp = safe_malloc (sizeof (LIST)); + head = tmp = mem_malloc (sizeof (LIST)); - tmp->data = safe_malloc (len); + tmp->data = mem_malloc (len); if (len) memcpy (tmp->data, data, len); tmp->next = NULL; @@ -246,8 +246,8 @@ void mutt_free_list (LIST ** list) while (*list) { p = *list; *list = (*list)->next; - FREE (&p->data); - FREE (&p); + mem_free (&p->data); + mem_free (&p); } } @@ -266,16 +266,16 @@ void mutt_free_header (HEADER ** h) return; mutt_free_envelope (&(*h)->env); mutt_free_body (&(*h)->content); - FREE (&(*h)->maildir_flags); - FREE (&(*h)->tree); - FREE (&(*h)->path); + mem_free (&(*h)->maildir_flags); + mem_free (&(*h)->tree); + mem_free (&(*h)->path); #ifdef MIXMASTER mutt_free_list (&(*h)->chain); #endif #if defined USE_POP || defined USE_IMAP || defined USE_NNTP - FREE (&(*h)->data); + mem_free (&(*h)->data); #endif - FREE (h); + mem_free (h); } /* returns true if the header contained in "s" is in list "t" */ @@ -621,26 +621,26 @@ void mutt_free_envelope (ENVELOPE ** p) rfc822_free_address (&(*p)->reply_to); rfc822_free_address (&(*p)->mail_followup_to); - FREE (&(*p)->list_post); - FREE (&(*p)->subject); + mem_free (&(*p)->list_post); + mem_free (&(*p)->subject); /* real_subj is just an offset to subject and shouldn't be freed */ - FREE (&(*p)->message_id); - FREE (&(*p)->supersedes); - FREE (&(*p)->date); - FREE (&(*p)->x_label); - FREE (&(*p)->organization); + mem_free (&(*p)->message_id); + mem_free (&(*p)->supersedes); + mem_free (&(*p)->date); + mem_free (&(*p)->x_label); + mem_free (&(*p)->organization); #ifdef USE_NNTP - FREE (&(*p)->newsgroups); - FREE (&(*p)->xref); - FREE (&(*p)->followup_to); - FREE (&(*p)->x_comment_to); + mem_free (&(*p)->newsgroups); + mem_free (&(*p)->xref); + mem_free (&(*p)->followup_to); + mem_free (&(*p)->x_comment_to); #endif mutt_buffer_free (&(*p)->spam); mutt_free_list (&(*p)->references); mutt_free_list (&(*p)->in_reply_to); mutt_free_list (&(*p)->userhdrs); - FREE (p); + mem_free (p); } /* move all the headers from extra not present in base into base */ @@ -704,9 +704,9 @@ void mutt_free_alias (ALIAS ** p) while (*p) { t = *p; *p = (*p)->next; - FREE (&t->name); + mem_free (&t->name); rfc822_free_address (&t->addr); - FREE (&t); + mem_free (&t); } } @@ -860,13 +860,13 @@ int mutt_check_overwrite (const char *attname, const char *path, str_replace (directory, fname); break; case 1: /* yes */ - FREE (directory); + mem_free (directory); break; case -1: /* abort */ - FREE (directory); + mem_free (directory); return -1; case 2: /* no */ - FREE (directory); + mem_free (directory); return 1; } } @@ -1148,7 +1148,7 @@ void mutt_FormatString (char *dest, /* output buffer */ } else { unsigned int bar = mutt_skipchars (src, "%\\"); - char *bar2 = safe_malloc (bar + 1); + char *bar2 = mem_malloc (bar + 1); strfcpy (bar2, src, bar + 1); while (bar--) { @@ -1156,7 +1156,7 @@ void mutt_FormatString (char *dest, /* output buffer */ wlen++; } col += mutt_strwidth (bar2); - FREE (&bar2); + mem_free (&bar2); } } *wptr = 0; @@ -1190,7 +1190,7 @@ FILE *mutt_open_read (const char *path, pid_t * thepid) s[len - 1] = 0; mutt_endwin (NULL); *thepid = mutt_create_filter (s, NULL, &f, NULL); - FREE (&s); + mem_free (&s); } else { if (stat (path, &s) < 0) @@ -1378,12 +1378,12 @@ void mutt_sleep (short s) BUFFER *mutt_buffer_init (BUFFER * b) { if (!b) { - b = safe_malloc (sizeof (BUFFER)); + b = mem_malloc (sizeof (BUFFER)); if (!b) return NULL; } else { - FREE(&b->data); + mem_free(&b->data); } memset (b, 0, sizeof (BUFFER)); return b; @@ -1424,9 +1424,9 @@ void mutt_buffer_free (BUFFER ** p) if (!p || !*p) return; - FREE (&(*p)->data); + mem_free (&(*p)->data); /* dptr is just an offset to data and shouldn't be freed */ - FREE (p); + mem_free (p); } /* dynamically grows a BUFFER to accomodate s, in increments of 128 bytes. @@ -1439,7 +1439,7 @@ void mutt_buffer_add (BUFFER * buf, const char *s, size_t len) if (buf->dptr + len + 1 > buf->data + buf->dsize) { offset = buf->dptr - buf->data; buf->dsize += len < 128 ? 128 : len + 1; - safe_realloc ((void **) &buf->data, buf->dsize); + mem_realloc ((void **) &buf->data, buf->dsize); buf->dptr = buf->data + offset; } memcpy (buf->dptr, s, len); @@ -1490,8 +1490,8 @@ void mutt_free_spam_list (SPAM_LIST ** list) p = *list; *list = (*list)->next; rx_free (&p->rx); - FREE(&p->template); - FREE(&p); + mem_free(&p->template); + mem_free(&p); } } @@ -1510,7 +1510,7 @@ int mutt_match_spam_list (const char *s, SPAM_LIST * l, char *text, int x) for (; l; l = l->next) { /* If this pattern needs more matches, expand pmatch. */ if (l->nmatch > nmatch) { - safe_realloc (&pmatch, l->nmatch * sizeof (regmatch_t)); + mem_realloc (&pmatch, l->nmatch * sizeof (regmatch_t)); nmatch = l->nmatch; } diff --git a/mx.c b/mx.c index e7a4db9..6cc2a3b 100644 --- a/mx.c +++ b/mx.c @@ -518,7 +518,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 +536,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 +559,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 +589,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 +613,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 +1117,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 +1150,7 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) } } else - FREE (&msg); + mem_free (&msg); return msg; } @@ -1179,7 +1179,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 +1201,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 +1210,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 +1219,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 +1228,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 +1277,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 +1297,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 +1342,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)) diff --git a/nntp/mx_nntp.c b/nntp/mx_nntp.c index 5229a1d..cd309ea 100644 --- a/nntp/mx_nntp.c +++ b/nntp/mx_nntp.c @@ -40,7 +40,7 @@ static int acl_check_nntp (CONTEXT* ctx, int bit) { /* called by nntp_init(); don't call elsewhere */ mx_t* nntp_reg_mx (void) { - mx_t* fmt = safe_calloc (1, sizeof (mx_t)); + mx_t* fmt = mem_calloc (1, sizeof (mx_t)); /* make up mx_t record... */ fmt->type = M_NNTP; diff --git a/nntp/newsrc.c b/nntp/newsrc.c index c5fa382..8c5e736 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -41,7 +41,7 @@ void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d) if (!s || !d) return; - l = safe_calloc (1, sizeof (LIST)); + l = mem_calloc (1, sizeof (LIST)); if (s->list) s->tail->next = l; else @@ -74,7 +74,7 @@ static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line) strfcpy (group, line, len); if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) { data = - (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1); + (NNTP_DATA *) mem_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1); data->group = (char *) data + sizeof (NNTP_DATA); strcpy (data->group, group); data->nserv = news; @@ -86,10 +86,10 @@ static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line) nntp_add_to_list (news, data); } else - FREE ((void **) &data->entries); + mem_free ((void **) &data->entries); data->rc = 1; - data->entries = safe_calloc (x * 2, sizeof (NEWSRC_ENTRY)); + data->entries = mem_calloc (x * 2, sizeof (NEWSRC_ENTRY)); data->max = x * 2; if (*p == ':') @@ -148,10 +148,10 @@ static int slurp_newsrc (NNTP_SERVER * news) return -1; } - buf = safe_malloc (sb.st_size + 1); + buf = mem_malloc (sb.st_size + 1); while (fgets (buf, sb.st_size + 1, fp)) nntp_parse_newsrc_line (news, buf); - FREE (&buf); + mem_free (&buf); mx_unlock_file (news->newsrc, fileno (fp), 0); fclose (fp); @@ -199,7 +199,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) set_option (OPTNEWSCACHE); - FREE (&news->cache); + mem_free (&news->cache); snprintf (buf, sizeof (buf), "%s/.index", dir); if (!(index = safe_fopen (buf, "a+"))) return 0; @@ -227,7 +227,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) else if (news->newsgroups) { if ((data = (NNTP_DATA *) hash_find (news->newsgroups, buf)) == NULL) { data = - (NNTP_DATA *) safe_calloc (1, + (NNTP_DATA *) mem_calloc (1, sizeof (NNTP_DATA) + str_len (buf) + 1); data->group = (char *) data + sizeof (NNTP_DATA); strcpy (data->group, buf); @@ -304,7 +304,7 @@ int nntp_parse_url (const char *server, ACCOUNT * acct, ret = mutt_account_fromurl (acct, &url); } - FREE (&c); + mem_free (&c); return ret; } @@ -315,7 +315,7 @@ void nntp_expand_path (char *line, size_t len, ACCOUNT * acct) url.path = str_dup (line); mutt_account_tourl (acct, &url); url_ciss_tostring (&url, line, len, 0); - FREE (&url.path); + mem_free (&url.path); } /* @@ -343,7 +343,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server) return NULL; } - buf = p = safe_calloc (str_len (server) + 10, sizeof (char)); + buf = p = mem_calloc (str_len (server) + 10, sizeof (char)); if (url_check_scheme (server) == U_UNKNOWN) { strcpy (buf, "nntp://"); p = strchr (buf, '\0'); @@ -351,11 +351,11 @@ NNTP_SERVER *mutt_select_newsserver (char *server) strcpy (p, server); if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file) { - FREE (&buf); + mem_free (&buf); mutt_error (_("%s is an invalid newsserver specification!"), server); return NULL; } - FREE (&buf); + mem_free (&buf); conn = mutt_conn_find (NULL, &acct); if (!conn) @@ -393,7 +393,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server) } /* New newsserver */ - serv = safe_calloc (1, sizeof (NNTP_SERVER)); + serv = mem_calloc (1, sizeof (NNTP_SERVER)); serv->conn = conn; serv->newsrc = str_dup (file); serv->newsgroups = hash_create (1009); @@ -406,9 +406,9 @@ NNTP_SERVER *mutt_select_newsserver (char *server) for (list = serv->list; list; list = list->next) list->data = NULL; mutt_free_list (&serv->list); - FREE (&serv->newsrc); - FREE (&serv->cache); - FREE (&serv); + mem_free (&serv->newsrc); + mem_free (&serv->cache); + mem_free (&serv); return NULL; } nntp_clear_cacheindex (serv); @@ -508,7 +508,7 @@ static void nntp_create_newsrc_line (NNTP_DATA * data, char **buf, len += *buflen; *buflen *= 2; line = *buf; - safe_realloc (buf, *buflen); + mem_realloc (buf, *buflen); line = *buf + (*pline - line); } strcpy (line, data->group); @@ -524,7 +524,7 @@ static void nntp_create_newsrc_line (NNTP_DATA * data, char **buf, *buflen *= 2; *pline = line; line = *buf; - safe_realloc (buf, *buflen); + mem_realloc (buf, *buflen); line = *buf + (*pline - line); } if (x) { @@ -572,7 +572,7 @@ void newsrc_gen_entries (CONTEXT * ctx) } if (!data->max) { - data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); + data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY)); data->max = 5; } @@ -594,7 +594,7 @@ void newsrc_gen_entries (CONTEXT * ctx) !ctx->hdrs[x]->read) { if (data->num >= data->max) { data->max = data->max * 2; - safe_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY)); + mem_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY)); } data->entries[data->num].first = first; data->entries[data->num].last = last - 1; @@ -614,7 +614,7 @@ void newsrc_gen_entries (CONTEXT * ctx) if (series && first <= data->lastLoaded) { if (data->num >= data->max) { data->max = data->max * 2; - safe_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY)); + mem_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY)); } data->entries[data->num].first = first; data->entries[data->num].last = data->lastLoaded; @@ -638,7 +638,7 @@ int mutt_newsrc_update (NNTP_SERVER * news) if (!news) return -1; llen = len = 10 * LONG_STRING; - line = buf = safe_calloc (1, len); + line = buf = mem_calloc (1, len); /* we will generate full newsrc here */ for (tmp = news->list; tmp; tmp = tmp->next) { data = (NNTP_DATA *) tmp->data; @@ -657,7 +657,7 @@ int mutt_newsrc_update (NNTP_SERVER * news) news->size = st.st_size; news->mtime = st.st_mtime; } - FREE (&buf); + mem_free (&buf); return r; } @@ -864,7 +864,7 @@ void nntp_delete_cache (NNTP_DATA * data) nntp_cache_expand (buf, data->cache); unlink (buf); - FREE (&data->cache); + mem_free (&data->cache); data->lastCached = 0; nntp_cache_expand (buf, ".index"); mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, @@ -879,7 +879,7 @@ NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER * news, char *group) return NULL; if (!(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) { data = - (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1); + (NNTP_DATA *) mem_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1); data->group = (char *) data + sizeof (NNTP_DATA); strcpy (data->group, group); data->nserv = news; @@ -920,7 +920,7 @@ NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER * news, char *group) !(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) return NULL; if (!data->max) { - data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); + data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY)); data->max = 5; } data->num = 1; @@ -944,7 +944,7 @@ NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER * news, char *group) !(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) return NULL; if (!data->max) { - data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); + data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY)); data->max = 5; } data->num = 1; diff --git a/nntp/nntp.c b/nntp/nntp.c index ac32993..ed934eb 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -300,7 +300,7 @@ static int mutt_nntp_fetch (NNTP_DATA * nntp_data, char *query, char *msg, ret = 0; line = 0; - inbuf = safe_malloc (sizeof (buf)); + inbuf = mem_malloc (sizeof (buf)); FOREVER { chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn, @@ -337,9 +337,9 @@ static int mutt_nntp_fetch (NNTP_DATA * nntp_data, char *query, char *msg, lenbuf = 0; } - safe_realloc (&inbuf, lenbuf + sizeof (buf)); + mem_realloc (&inbuf, lenbuf + sizeof (buf)); } - FREE (&inbuf); + mem_free (&inbuf); funct (NULL, data); } while (!done); @@ -461,7 +461,7 @@ static int parse_description (char *line, void *n) debug_print (2, ("group: %s, desc: %s\n", line, d)); if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL && str_cmp (d, data->desc)) { - FREE (&data->desc); + mem_free (&data->desc); data->desc = str_dup (d); } return 0; @@ -551,7 +551,7 @@ static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr) hdr->received = hdr->date_sent; break; case 4: - FREE (&hdr->env->message_id); + mem_free (&hdr->env->message_id); hdr->env->message_id = str_dup (b); break; case 5: @@ -566,7 +566,7 @@ static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr) break; case 8: if (!hdr->read) - FREE (&hdr->env->xref); + mem_free (&hdr->env->xref); b = b + 6; /* skips the "Xref: " */ hdr->env->xref = str_dup (b); nntp_parse_xref (ctx, nntp_data->group, b, hdr); @@ -659,7 +659,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, fc.ctx = ctx; fc.base = first; fc.last = last; - fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short)); + fc.messages = mem_calloc (last - first + 1, sizeof (unsigned short)); if (nntp_data->nserv->hasLISTGROUP) { snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != @@ -669,7 +669,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, #ifdef DEBUG nntp_error ("nntp_fetch_headers()", buf); #endif - FREE (&fc.messages); + mem_free (&fc.messages); return -1; } } @@ -680,7 +680,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, mutt_nntp_query (nntp_data, buf, sizeof (buf)); if (sscanf (buf + 4, "%d %u %u %s", &num, &fc.first, &fc.last, buf) != 4) { mutt_error (_("GROUP command failed: %s"), buf); - FREE (&fc.messages); + mem_free (&fc.messages); return (-1); } else { @@ -721,7 +721,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, } num = last - first + 1; if (num <= 0) { - FREE (&fc.messages); + mem_free (&fc.messages); return 0; } @@ -744,7 +744,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, #ifdef DEBUG nntp_error ("nntp_fetch_headers()", buf); #endif - FREE (&fc.messages); + mem_free (&fc.messages); return -1; } /* fetched OK */ @@ -773,14 +773,14 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, else mutt_free_header (&h); /* skip it */ if (ret == -1) { - FREE (&fc.messages); + mem_free (&fc.messages); return -1; } if (current > nntp_data->lastLoaded) nntp_data->lastLoaded = current; } - FREE (&fc.messages); + mem_free (&fc.messages); nntp_data->lastLoaded = last; mutt_clear_error (); return 0; @@ -814,7 +814,7 @@ int nntp_open_mailbox (CONTEXT * ctx) /* create NNTP-specific state struct if nof found in list */ if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL) { - nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + str_len (buf) + 1); + nntp_data = mem_calloc (1, sizeof (NNTP_DATA) + str_len (buf) + 1); nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA); strcpy (nntp_data->group, buf); hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0); @@ -909,7 +909,7 @@ int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) mutt_mktemp (path); cache->path = str_dup (path); if (!(msg->fp = safe_fopen (path, "w+"))) { - FREE (&cache->path); + mem_free (&cache->path); return -1; } @@ -931,7 +931,7 @@ int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) if (ret) { fclose (msg->fp); unlink (path); - FREE (&cache->path); + mem_free (&cache->path); return -1; } @@ -1062,7 +1062,7 @@ static void nntp_free_acache (NNTP_DATA * data) for (i = 0; i < NNTP_CACHE_LEN; i++) { if (data->acache[i].path) { unlink (data->acache[i].path); - FREE (&data->acache[i].path); + mem_free (&data->acache[i].path); } } } @@ -1073,11 +1073,11 @@ void nntp_delete_data (void *p) if (!p) return; - FREE (&data->entries); - FREE (&data->desc); - FREE (&data->cache); + mem_free (&data->entries); + mem_free (&data->desc); + mem_free (&data->cache); nntp_free_acache (data); - FREE (p); + mem_free (p); } int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2) @@ -1184,7 +1184,7 @@ static int _nntp_check_mailbox (CONTEXT * ctx, NNTP_DATA * nntp_data) /* active was renumbered? */ if (last < nntp_data->lastLoaded) { if (!nntp_data->max) { - nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); + nntp_data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY)); nntp_data->max = 5; } nntp_data->lastCached = 0; @@ -1224,7 +1224,7 @@ static int add_group (char *buf, void *serv) return 0; if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL) { n++; - nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1); + nntp_data = mem_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1); nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA); strcpy (nntp_data->group, group); nntp_data->nserv = s; @@ -1241,7 +1241,7 @@ static int add_group (char *buf, void *serv) else nntp_data->allowed = 0; if (nntp_data->desc) - FREE (&nntp_data->desc); + mem_free (&nntp_data->desc); if (*desc) nntp_data->desc = str_dup (desc); if (nntp_data->rc || nntp_data->lastCached) @@ -1347,7 +1347,7 @@ int nntp_get_cache_all (NNTP_SERVER * serv) return 0; } else { - FREE (&serv->cache); + mem_free (&serv->cache); return -1; } } @@ -1444,7 +1444,7 @@ static int check_children (char *s, void *c) if (cc->ctx->hdrs[i]->article_num == n) return 0; if (cc->num >= cc->max) - safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25)); + mem_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25)); cc->child[cc->num++] = n; return 0; @@ -1475,9 +1475,9 @@ int nntp_check_children (CONTEXT * ctx, const char *msgid) cc.ctx = ctx; cc.num = 0; cc.max = 25; - cc.child = safe_malloc (sizeof (unsigned int) * 25); + cc.child = mem_malloc (sizeof (unsigned int) * 25); if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0)) { - FREE (&cc.child); + mem_free (&cc.child); return -1; } /* dont try to read the xover cache. check_children() already @@ -1497,6 +1497,6 @@ int nntp_check_children (CONTEXT * ctx, const char *msgid) } if (tmp) set_option (OPTNEWSCACHE); - FREE (&cc.child); + mem_free (&cc.child); return ret; } diff --git a/pager.c b/pager.c index d3a4b4e..ecb430d 100644 --- a/pager.c +++ b/pager.c @@ -345,8 +345,8 @@ static void cleanup_quote (struct q_class_t **QuoteList) cleanup_quote (&((*QuoteList)->down)); ptr = (*QuoteList)->next; if ((*QuoteList)->prefix) - FREE (&(*QuoteList)->prefix); - FREE (QuoteList); + mem_free (&(*QuoteList)->prefix); + mem_free (QuoteList); *QuoteList = ptr; } @@ -367,7 +367,7 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, /* not much point in classifying quotes... */ if (*QuoteList == NULL) { - class = (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t)); + class = (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t)); class->color = ColorQuote[0]; *QuoteList = class; } @@ -389,8 +389,8 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, if (tmp == NULL) { /* add a node above q_list */ tmp = - (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t)); - tmp->prefix = (char *) safe_calloc (1, length + 1); + (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t)); + tmp->prefix = (char *) mem_calloc (1, length + 1); strncpy (tmp->prefix, qptr, length); tmp->length = length; @@ -491,10 +491,10 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, /* found shorter common prefix */ if (tmp == NULL) { /* add a node above q_list */ - tmp = (struct q_class_t *) safe_calloc (1, + tmp = (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t)); - tmp->prefix = (char *) safe_calloc (1, length + 1); + tmp->prefix = (char *) mem_calloc (1, length + 1); strncpy (tmp->prefix, qptr, length); tmp->length = length; @@ -589,8 +589,8 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, /* still not found so far: add it as a sibling to the current node */ if (class == NULL) { tmp = - (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t)); - tmp->prefix = (char *) safe_calloc (1, length + 1); + (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t)); + tmp->prefix = (char *) mem_calloc (1, length + 1); strncpy (tmp->prefix, qptr, length); tmp->length = length; @@ -622,8 +622,8 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, if (class == NULL) { /* not found so far: add it as a top level class */ - class = (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t)); - class->prefix = (char *) safe_calloc (1, length + 1); + class = (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t)); + class->prefix = (char *) mem_calloc (1, length + 1); strncpy (class->prefix, qptr, length); class->length = length; new_class_color (class, q_level); @@ -693,7 +693,7 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last, /* oops... */ if (lineInfo[i].chunks) { lineInfo[i].chunks = 0; - safe_realloc (&(lineInfo[n].syntax), sizeof (struct syntax_t)); + mem_realloc (&(lineInfo[n].syntax), sizeof (struct syntax_t)); } lineInfo[i++].type = MT_COLOR_SIGNATURE; } @@ -757,7 +757,7 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last, if (pmatch[0].rm_eo != pmatch[0].rm_so) { if (!found) { if (++(lineInfo[n].chunks) > 1) - safe_realloc (&(lineInfo[n].syntax), + mem_realloc (&(lineInfo[n].syntax), (lineInfo[n].chunks) * sizeof (struct syntax_t)); } @@ -1140,12 +1140,12 @@ display_line (FILE * f, long *last_pos, struct line_t **lineInfo, int n, } if (*last == *max) { - safe_realloc (lineInfo, sizeof (struct line_t) * (*max += LINES)); + mem_realloc (lineInfo, sizeof (struct line_t) * (*max += LINES)); for (ch = *last; ch < *max; ch++) { memset (&((*lineInfo)[ch]), 0, sizeof (struct line_t)); (*lineInfo)[ch].type = -1; (*lineInfo)[ch].search_cnt = -1; - (*lineInfo)[ch].syntax = safe_malloc (sizeof (struct syntax_t)); + (*lineInfo)[ch].syntax = mem_malloc (sizeof (struct syntax_t)); ((*lineInfo)[ch].syntax)[0].first = ((*lineInfo)[ch].syntax)[0].last = -1; } @@ -1217,10 +1217,10 @@ display_line (FILE * f, long *last_pos, struct line_t **lineInfo, int n, (SearchRE, (char *) fmt + offset, 1, pmatch, (offset ? REG_NOTBOL : 0)) == 0) { if (++((*lineInfo)[n].search_cnt) > 1) - safe_realloc (&((*lineInfo)[n].search), + mem_realloc (&((*lineInfo)[n].search), ((*lineInfo)[n].search_cnt) * sizeof (struct syntax_t)); else - (*lineInfo)[n].search = safe_malloc (sizeof (struct syntax_t)); + (*lineInfo)[n].search = mem_malloc (sizeof (struct syntax_t)); pmatch[0].rm_so += offset; pmatch[0].rm_eo += offset; ((*lineInfo)[n].search)[(*lineInfo)[n].search_cnt - 1].first = @@ -1457,12 +1457,12 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) mutt_set_flag (Context, extra->hdr, M_READ, 1); } - lineInfo = safe_malloc (sizeof (struct line_t) * (maxLine = LINES)); + lineInfo = mem_malloc (sizeof (struct line_t) * (maxLine = LINES)); for (i = 0; i < maxLine; i++) { memset (&lineInfo[i], 0, sizeof (struct line_t)); lineInfo[i].type = -1; lineInfo[i].search_cnt = -1; - lineInfo[i].syntax = safe_malloc (sizeof (struct syntax_t)); + lineInfo[i].syntax = mem_malloc (sizeof (struct syntax_t)); (lineInfo[i].syntax)[0].first = (lineInfo[i].syntax)[0].last = -1; } @@ -1540,7 +1540,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) lines = Resize->line; redraw |= REDRAW_SIGWINCH; - FREE (&Resize); + mem_free (&Resize); } #endif @@ -1711,7 +1711,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) lines++; if (flags & M_PAGER_RETWINCH) { - Resize = safe_malloc (sizeof (struct resize)); + Resize = mem_malloc (sizeof (struct resize)); Resize->line = lines; Resize->SearchCompiled = SearchCompiled; @@ -1729,9 +1729,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) lineInfo[i].search_cnt = -1; lineInfo[i].quote = NULL; - safe_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t)); + mem_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t)); if (SearchCompiled && lineInfo[i].search) - FREE (&(lineInfo[i].search)); + mem_free (&(lineInfo[i].search)); } lastLine = 0; @@ -1907,7 +1907,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) regfree (&SearchRE); for (i = 0; i < lastLine; i++) { if (lineInfo[i].search) - FREE (&(lineInfo[i].search)); + mem_free (&(lineInfo[i].search)); lineInfo[i].search_cnt = -1; } } @@ -1921,7 +1921,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) for (i = 0; i < maxLine; i++) { /* cleanup */ if (lineInfo[i].search) - FREE (&(lineInfo[i].search)); + mem_free (&(lineInfo[i].search)); lineInfo[i].search_cnt = -1; } SearchFlag = 0; @@ -2211,9 +2211,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) lineInfo[i].search_cnt = -1; lineInfo[i].quote = NULL; - safe_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t)); + mem_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t)); if (SearchCompiled && lineInfo[i].search) - FREE (&(lineInfo[i].search)); + mem_free (&(lineInfo[i].search)); } if (SearchCompiled) { @@ -2593,15 +2593,15 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) cleanup_quote (&QuoteList); for (i = 0; i < maxLine; i++) { - FREE (&(lineInfo[i].syntax)); + mem_free (&(lineInfo[i].syntax)); if (SearchCompiled && lineInfo[i].search) - FREE (&(lineInfo[i].search)); + mem_free (&(lineInfo[i].search)); } if (SearchCompiled) { regfree (&SearchRE); SearchCompiled = 0; } - FREE (&lineInfo); + mem_free (&lineInfo); if (index) mutt_menuDestroy (&index); return (rc != -1 ? rc : 0); diff --git a/parse.c b/parse.c index 7cb195f..bd0772a 100644 --- a/parse.c +++ b/parse.c @@ -72,7 +72,7 @@ static char *read_rfc822_line (FILE * f, char *line, size_t * linelen) if (*linelen < offset + STRING) { /* grow the buffer */ *linelen += STRING; - safe_realloc (&line, *linelen); + mem_realloc (&line, *linelen); buf = line + offset; } } @@ -108,7 +108,7 @@ LIST *mutt_parse_references (char *s, int in_reply_to) else if (o) { m = str_len (s); if (s[m - 1] == '>') { - new = safe_malloc (sizeof (char) * (n + m + 1)); + new = mem_malloc (sizeof (char) * (n + m + 1)); strcpy (new, o); /* __STRCPY_CHECKED__ */ strcpy (new + n, s); /* __STRCPY_CHECKED__ */ } @@ -122,9 +122,9 @@ LIST *mutt_parse_references (char *s, int in_reply_to) */ if (!(at = strchr (new, '@')) || strchr (at + 1, '@') || (in_reply_to && at - new <= 8)) - FREE (&new); + mem_free (&new); else { - t = (LIST *) safe_malloc (sizeof (LIST)); + t = (LIST *) mem_malloc (sizeof (LIST)); t->data = new; t->next = lst; lst = t; @@ -183,7 +183,7 @@ static PARAMETER *parse_parameters (const char *s) new = mutt_new_parameter (); - new->attribute = safe_malloc (i + 1); + new->attribute = mem_malloc (i + 1); memcpy (new->attribute, s, i); new->attribute[i] = 0; @@ -299,7 +299,7 @@ void mutt_parse_content_type (char *s, BODY * ct) char *pc; char *subtype; - FREE (&ct->subtype); + mem_free (&ct->subtype); mutt_free_parameter (&ct->parameter); /* First extract any existing parameters */ @@ -412,7 +412,7 @@ BODY *mutt_read_mime_header (FILE * fp, int digest) { BODY *p = mutt_new_body (); char *c; - char *line = safe_malloc (LONG_STRING); + char *line = mem_malloc (LONG_STRING); size_t linelen = LONG_STRING; p->hdr_offset = ftell (fp); @@ -470,7 +470,7 @@ BODY *mutt_read_mime_header (FILE * fp, int digest) else if (p->type == TYPEMESSAGE && !p->subtype) p->subtype = str_dup ("rfc822"); - FREE (&line); + mem_free (&line); return (p); } @@ -912,7 +912,7 @@ static char *extract_message_id (const char *s) if ((s = strchr (s, '<')) == NULL || (p = strchr (s, '>')) == NULL) return (NULL); l = (size_t) (p - s) + 1; - r = safe_malloc (l + 1); + r = mem_malloc (l + 1); memcpy (r, s, l); r[l] = 0; return (r); @@ -1080,7 +1080,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, /* Take the first mailto URL */ if (url_check_scheme (beg) == U_MAILTO) { - FREE (&e->list_post); + mem_free (&e->list_post); e->list_post = str_substrdup (beg, end); break; } @@ -1098,7 +1098,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, } else if (!ascii_strcasecmp (line + 1, "essage-id")) { /* We add a new "Message-Id:" when building a message */ - FREE (&e->message_id); + mem_free (&e->message_id); e->message_id = extract_message_id (p); matched = 1; } @@ -1119,7 +1119,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, #ifdef USE_NNTP case 'n': if (!str_casecmp (line + 1, "ewsgroups")) { - FREE (&e->newsgroups); + mem_free (&e->newsgroups); str_skip_trailws (p); e->newsgroups = str_dup (str_skip_initws (p)); matched = 1; @@ -1293,7 +1293,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs, { ENVELOPE *e = mutt_new_envelope (); LIST *last = NULL; - char *line = safe_malloc (LONG_STRING); + char *line = mem_malloc (LONG_STRING); char *p; long loc; int matched; @@ -1384,7 +1384,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs, } - FREE (&line); + mem_free (&line); if (hdr) { hdr->content->hdr_offset = hdr->offset; diff --git a/pattern.c b/pattern.c index 8b92597..f804c74 100644 --- a/pattern.c +++ b/pattern.c @@ -229,15 +229,15 @@ int eat_regexp (pattern_t * pat, BUFFER * s, BUFFER * err) snprintf (err->data, err->dsize, _("Error in expression: %s"), s->dptr); return (-1); } - pat->rx = safe_malloc (sizeof (regex_t)); + pat->rx = mem_malloc (sizeof (regex_t)); r = REGCOMP (pat->rx, buf.data, REG_NEWLINE | REG_NOSUB | mutt_which_case (buf.data)); - FREE (&buf.data); + mem_free (&buf.data); if (r) { regerror (r, pat->rx, err->data, err->dsize); regfree (pat->rx); - FREE (&pat->rx); + mem_free (&pat->rx); return (-1); } return 0; @@ -557,7 +557,7 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) if (isdigit ((unsigned char) *pc)) { /* mininum date specified */ if ((pc = getDate (pc, &min, err)) == NULL) { - FREE (&buffer.data); + mem_free (&buffer.data); return (-1); } haveMin = TRUE; @@ -590,7 +590,7 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) max.tm_mday = min.tm_mday; if (!parse_date_range (pc, &min, &max, haveMin, &baseMin, err)) { /* bail out on any parsing error */ - FREE (&buffer.data); + mem_free (&buffer.data); return (-1); } } @@ -602,7 +602,7 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) pat->min = mutt_mktime (&min, 1); pat->max = mutt_mktime (&max, 1); - FREE (&buffer.data); + mem_free (&buffer.data); return 0; } @@ -643,11 +643,11 @@ void mutt_pattern_free (pattern_t ** pat) if (tmp->rx) { regfree (tmp->rx); - FREE (&tmp->rx); + mem_free (&tmp->rx); } if (tmp->child) mutt_pattern_free (&tmp->child); - FREE (&tmp); + mem_free (&tmp); } } @@ -768,11 +768,11 @@ pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err) /* compile the sub-expression */ buf = str_substrdup (ps.dptr + 1, p); if ((tmp = mutt_pattern_comp (buf, flags, err)) == NULL) { - FREE (&buf); + mem_free (&buf); mutt_pattern_free (&curlist); return NULL; } - FREE (&buf); + mem_free (&buf); if (last) last->next = tmp; else @@ -1149,7 +1149,7 @@ int mutt_pattern_func (int op, char *prompt) err.data = error; err.dsize = sizeof (error); if ((pat = mutt_pattern_comp (buf, M_FULL_MSG, &err)) == NULL) { - FREE (&simple); + mem_free (&simple); mutt_error ("%s", err.data); return (-1); } @@ -1208,7 +1208,7 @@ int mutt_pattern_func (int op, char *prompt) mutt_clear_error (); if (op == M_LIMIT) { - FREE (&Context->pattern); + mem_free (&Context->pattern); if (Context->limit_pattern) mutt_pattern_free (&Context->limit_pattern); if (!Context->vcount) { @@ -1229,7 +1229,7 @@ int mutt_pattern_func (int op, char *prompt) Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err); } } - FREE (&simple); + mem_free (&simple); mutt_pattern_free (&pat); return 0; } diff --git a/pgp.c b/pgp.c index 5e886db..995ec13 100644 --- a/pgp.c +++ b/pgp.c @@ -151,7 +151,7 @@ static int pgp_copy_checksig (FILE * fpin, FILE * fpout) fputs (line, fpout); fputc ('\n', fpout); } - FREE (&line); + mem_free (&line); } else { debug_print (2, ("No pattern.\n")); @@ -1100,7 +1100,7 @@ char *pgp_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc) k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING); } else if (r == -1) { - FREE (&keylist); + mem_free (&keylist); rfc822_free_address (&tmp); rfc822_free_address (&addr); return NULL; @@ -1117,7 +1117,7 @@ char *pgp_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc) if ((key = pgp_ask_for_key (buf, q->mailbox, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL) { - FREE (&keylist); + mem_free (&keylist); rfc822_free_address (&tmp); rfc822_free_address (&addr); return NULL; @@ -1130,7 +1130,7 @@ char *pgp_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc) bypass_selection: keylist_size += str_len (keyID) + 4; - safe_realloc (&keylist, keylist_size); + mem_realloc (&keylist, keylist_size); sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */ keyID); keylist_used = str_len (keylist); diff --git a/pgpkey.c b/pgpkey.c index 4c476c9..68ca6ff 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -450,7 +450,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, ADDRESS * p, const char *s) if (i == keymax) { keymax += 5; - safe_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax); + mem_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax); } KeyTable[i++] = a; @@ -622,7 +622,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, ADDRESS * p, const char *s) } mutt_menuDestroy (&menu); - FREE (&KeyTable); + mem_free (&KeyTable); set_option (OPTNEEDREDRAW); @@ -658,7 +658,7 @@ pgp_key_t pgp_ask_for_key (char *tag, char *whatfor, if (l) str_replace (&l->dflt, resp); else { - l = safe_malloc (sizeof (struct pgp_cache)); + l = mem_malloc (sizeof (struct pgp_cache)); l->next = id_defaults; id_defaults = l; l->what = str_dup (whatfor); @@ -767,7 +767,7 @@ static LIST *pgp_add_string_to_hints (LIST * hints, const char *str) hints = mutt_add_list (hints, t); } - FREE (&scratch); + mem_free (&scratch); return hints; } diff --git a/pgplib.c b/pgplib.c index c3e5af1..26b029b 100644 --- a/pgplib.c +++ b/pgplib.c @@ -116,7 +116,7 @@ void pgp_free_sig (pgp_sig_t ** sigp) for (sp = *sigp; sp; sp = q) { q = sp->next; - FREE (&sp); + mem_free (&sp); } *sigp = NULL; @@ -131,8 +131,8 @@ void pgp_free_uid (pgp_uid_t ** upp) for (up = *upp; up; up = q) { q = up->next; pgp_free_sig (&up->sigs); - FREE (&up->addr); - FREE (&up); + mem_free (&up->addr); + mem_free (&up); } *upp = NULL; @@ -144,7 +144,7 @@ pgp_uid_t *pgp_copy_uids (pgp_uid_t * up, pgp_key_t parent) pgp_uid_t **lp = &l; for (; up; up = up->next) { - *lp = safe_calloc (1, sizeof (pgp_uid_t)); + *lp = mem_calloc (1, sizeof (pgp_uid_t)); (*lp)->trust = up->trust; (*lp)->flags = up->flags; (*lp)->addr = str_dup (up->addr); @@ -165,8 +165,8 @@ static void _pgp_free_key (pgp_key_t * kpp) kp = *kpp; pgp_free_uid (&kp->address); - FREE (&kp->keyid); - FREE (kpp); + mem_free (&kp->keyid); + mem_free (kpp); } pgp_key_t pgp_remove_key (pgp_key_t * klist, pgp_key_t key) diff --git a/pgplib.h b/pgplib.h index f93107d..e6f7c1f 100644 --- a/pgplib.h +++ b/pgplib.h @@ -71,6 +71,6 @@ short pgp_get_abilities (unsigned char); void pgp_free_key (pgp_key_t * kpp); -#define pgp_new_keyinfo() safe_calloc (sizeof *((pgp_key_t)0), 1) +#define pgp_new_keyinfo() mem_calloc (sizeof *((pgp_key_t)0), 1) #endif /* CRYPT_BACKEND_CLASSIC_PGP */ diff --git a/pgppacket.c b/pgppacket.c index dd241fe..206f13c 100644 --- a/pgppacket.c +++ b/pgppacket.c @@ -66,7 +66,7 @@ unsigned char *pgp_read_packet (FILE * fp, size_t * len) if (!plen) { plen = CHUNKSIZE; - pbuf = safe_malloc (plen); + pbuf = mem_malloc (plen); } if (fread (&ctb, 1, 1, fp) < 1) { @@ -200,5 +200,5 @@ bail: void pgp_release_packet (void) { plen = 0; - FREE (&pbuf); + mem_free (&pbuf); } diff --git a/pgppubring.c b/pgppubring.c index 4ded33e..159a9d5 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -252,7 +252,7 @@ static pgp_key_t pgp_parse_pgp2_key (unsigned char *buff, size_t l) bailout: - FREE (&p); + mem_free (&p); return NULL; } @@ -636,7 +636,7 @@ static pgp_key_t pgp_parse_keyblock (FILE * fp) case PT_SIG: { if (lsig) { - pgp_sig_t *signature = safe_calloc (sizeof (pgp_sig_t), 1); + pgp_sig_t *signature = mem_calloc (sizeof (pgp_sig_t), 1); *lsig = signature; lsig = &signature->next; @@ -667,12 +667,12 @@ static pgp_key_t pgp_parse_keyblock (FILE * fp) if (!addr) break; - chr = safe_malloc (l); + chr = mem_malloc (l); memcpy (chr, buff + 1, l - 1); chr[l - 1] = '\0'; - *addr = uid = safe_calloc (1, sizeof (pgp_uid_t)); /* XXX */ + *addr = uid = mem_calloc (1, sizeof (pgp_uid_t)); /* XXX */ uid->addr = chr; uid->parent = p; uid->trust = 0; @@ -744,10 +744,10 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], size_t error_buf_len; error_buf_len = sizeof ("fopen: ") - 1 + str_len (ringfile) + 1; - error_buf = safe_malloc (error_buf_len); + error_buf = mem_malloc (error_buf_len); snprintf (error_buf, error_buf_len, "fopen: %s", ringfile); perror (error_buf); - FREE (&error_buf); + mem_free (&error_buf); return; } @@ -764,7 +764,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], keypos = pos; } else if (pt == PT_NAME) { - char *tmp = safe_malloc (l); + char *tmp = mem_malloc (l); memcpy (tmp, buff + 1, l - 1); tmp[l - 1] = '\0'; @@ -785,7 +785,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], pgp_free_key (&p); } - FREE (&tmp); + mem_free (&tmp); } FGETPOS (rfp, pos); diff --git a/pop/mx_pop.c b/pop/mx_pop.c index ae1f702..3262dca 100644 --- a/pop/mx_pop.c +++ b/pop/mx_pop.c @@ -39,7 +39,7 @@ static int acl_check_pop (CONTEXT* ctx, int bit) { } mx_t* pop_reg_mx (void) { - mx_t* fmt = safe_calloc (1, sizeof (mx_t)); + mx_t* fmt = mem_calloc (1, sizeof (mx_t)); /* make up mx_t record... */ fmt->type = M_POP; diff --git a/pop/pop.c b/pop/pop.c index 87912b7..01f8e93 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -240,10 +240,10 @@ int pop_open_mailbox (CONTEXT * ctx) if (!conn) return -1; - FREE (&ctx->path); + mem_free (&ctx->path); ctx->path = str_dup (buf); - pop_data = safe_calloc (1, sizeof (POP_DATA)); + pop_data = mem_calloc (1, sizeof (POP_DATA)); pop_data->conn = conn; ctx->data = pop_data; @@ -285,7 +285,7 @@ static void pop_clear_cache (POP_DATA * pop_data) for (i = 0; i < POP_CACHE_LEN; i++) { if (pop_data->cache[i].path) { unlink (pop_data->cache[i].path); - FREE (&pop_data->cache[i].path); + mem_free (&pop_data->cache[i].path); } } } @@ -343,7 +343,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) else { /* clear the previous entry */ unlink (cache->path); - FREE (&cache->path); + mem_free (&cache->path); } } @@ -516,7 +516,7 @@ void pop_fetch_mail (void) return; } - url = p = safe_calloc (strlen (PopHost) + 7, sizeof (char)); + url = p = mem_calloc (strlen (PopHost) + 7, sizeof (char)); if (url_check_scheme (PopHost) == U_UNKNOWN) { strcpy (url, "pop://"); /* __STRCPY_CHECKED__ */ p = strchr (url, '\0'); @@ -524,7 +524,7 @@ void pop_fetch_mail (void) strcpy (p, PopHost); /* __STRCPY_CHECKED__ */ ret = pop_parse_path (url, &acct); - FREE (&url); + mem_free (&url); if (ret) { mutt_error (_("%s is an invalid POP path"), PopHost); return; @@ -534,12 +534,12 @@ void pop_fetch_mail (void) if (!conn) return; - pop_data = safe_calloc (1, sizeof (POP_DATA)); + pop_data = mem_calloc (1, sizeof (POP_DATA)); pop_data->conn = conn; if (pop_open_connection (pop_data) < 0) { mutt_socket_free (pop_data->conn); - FREE (&pop_data); + mem_free (&pop_data); return; } @@ -641,11 +641,11 @@ finish: if (pop_query (pop_data, buffer, sizeof (buffer)) == PQ_NOT_CONNECTED) goto fail; mutt_socket_close (conn); - FREE (&pop_data); + mem_free (&pop_data); return; fail: mutt_error _("Server closed connection!"); mutt_socket_close (conn); - FREE (&pop_data); + mem_free (&pop_data); } diff --git a/pop/pop_auth.c b/pop/pop_auth.c index 194f33b..5af14b7 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -138,7 +138,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) /* sasl_client_st(art|ep) allocate pc with malloc, expect me to * free it */ #ifndef USE_SASL2 - FREE (&pc); + mem_free (&pc); #endif } } @@ -174,7 +174,7 @@ void pop_apop_timestamp (POP_DATA * pop_data, char *buf) { char *p1, *p2; - FREE (&pop_data->timestamp); + mem_free (&pop_data->timestamp); if ((p1 = strchr (buf, '<')) && (p2 = strchr (p1, '>'))) { p2[1] = '\0'; @@ -349,7 +349,7 @@ pop_query_status pop_authenticate (POP_DATA * pop_data) method = comma; } - FREE (&methods); + mem_free (&methods); } else { /* Fall back to default: any authenticator */ diff --git a/pop/pop_lib.c b/pop/pop_lib.c index 2cd84f0..143868e 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -53,7 +53,7 @@ int pop_parse_path (const char *path, ACCOUNT * acct) ret = 0; } - FREE (&c); + mem_free (&c); return ret; } @@ -84,7 +84,7 @@ static int fetch_capa (char *line, void *data) char *c; if (!ascii_strncasecmp (line, "SASL", 4)) { - FREE (&pop_data->auth_list); + mem_free (&pop_data->auth_list); c = line + 4; SKIPWS (c); pop_data->auth_list = str_dup (c); @@ -111,11 +111,11 @@ static int fetch_auth (char *line, void *data) POP_DATA *pop_data = (POP_DATA *) data; if (!pop_data->auth_list) { - pop_data->auth_list = safe_malloc (strlen (line) + 1); + pop_data->auth_list = mem_malloc (strlen (line) + 1); *pop_data->auth_list = '\0'; } else { - safe_realloc (&pop_data->auth_list, + mem_realloc (&pop_data->auth_list, strlen (pop_data->auth_list) + strlen (line) + 2); strcat (pop_data->auth_list, " "); /* __STRCAT_CHECKED__ */ } @@ -148,7 +148,7 @@ static pop_query_status pop_capabilities (POP_DATA * pop_data, int mode) pop_data->resp_codes = 0; pop_data->expire = 1; pop_data->login_delay = 0; - FREE (&pop_data->auth_list); + mem_free (&pop_data->auth_list); } /* Execute CAPA command */ @@ -443,7 +443,7 @@ pop_query_status pop_fetch_data (POP_DATA * pop_data, char *query, char *msg, if (ret != PQ_OK) return ret; - inbuf = safe_malloc (sizeof (buf)); + inbuf = mem_malloc (sizeof (buf)); FOREVER { chunk = @@ -476,10 +476,10 @@ pop_query_status pop_fetch_data (POP_DATA * pop_data, char *query, char *msg, lenbuf = 0; } - safe_realloc (&inbuf, lenbuf + sizeof (buf)); + mem_realloc (&inbuf, lenbuf + sizeof (buf)); } - FREE (&inbuf); + mem_free (&inbuf); return ret; } diff --git a/postpone.c b/postpone.c index 122a6c8..67128ed 100644 --- a/postpone.c +++ b/postpone.c @@ -248,7 +248,7 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, if (!PostContext->msgcount) { PostCount = 0; mx_close_mailbox (PostContext, NULL); - FREE (&PostContext); + mem_free (&PostContext); mutt_error _("No postponed messages."); return (-1); @@ -260,13 +260,13 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, } else if ((h = select_msg ()) == NULL) { mx_close_mailbox (PostContext, NULL); - FREE (&PostContext); + mem_free (&PostContext); return (-1); } if (mutt_prepare_template (NULL, PostContext, hdr, h, 0) < 0) { mx_fastclose_mailbox (PostContext); - FREE (&PostContext); + mem_free (&PostContext); return (-1); } @@ -285,7 +285,7 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, mx_close_mailbox (PostContext, NULL); set_quadoption (OPT_DELETE, opt_delete); - FREE (&PostContext); + mem_free (&PostContext); for (tmp = hdr->env->userhdrs; tmp;) { if (ascii_strncasecmp ("X-Mutt-References:", tmp->data, 18) == 0) { @@ -524,8 +524,8 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, newhdr->content->length = hdr->content->length; mutt_parse_part (fp, newhdr->content); - FREE (&newhdr->env->message_id); - FREE (&newhdr->env->mail_followup_to); /* really? */ + mem_free (&newhdr->env->message_id); + mem_free (&newhdr->env->mail_followup_to); /* really? */ /* decrypt pgp/mime encoded messages */ diff --git a/protos.h b/protos.h index a4d56ef..43ade4c 100644 --- a/protos.h +++ b/protos.h @@ -49,10 +49,10 @@ int _mutt_aside_thread (HEADER *, short, short); int _mutt_traverse_thread (CONTEXT * ctx, HEADER * hdr, int flag); -#define mutt_new_parameter() safe_calloc (1, sizeof (PARAMETER)) -#define mutt_new_header() safe_calloc (1, sizeof (HEADER)) -#define mutt_new_envelope() safe_calloc (1, sizeof (ENVELOPE)) -#define mutt_new_enter_state() safe_calloc (1, sizeof (ENTER_STATE)) +#define mutt_new_parameter() mem_calloc (1, sizeof (PARAMETER)) +#define mutt_new_header() mem_calloc (1, sizeof (HEADER)) +#define mutt_new_envelope() mem_calloc (1, sizeof (ENVELOPE)) +#define mutt_new_enter_state() mem_calloc (1, sizeof (ENTER_STATE)) typedef const char *format_t (char *, size_t, char, const char *, const char *, const char *, const char *, @@ -398,7 +398,7 @@ int mutt_wctoutf8 (char *s, unsigned int c); (option (OPTLOCALES) ? 0 : (wc >= 0xa0))) #endif -#define new_pattern() safe_calloc(1, sizeof (pattern_t)) +#define new_pattern() mem_calloc(1, sizeof (pattern_t)) int mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT * ctx, HEADER * h); diff --git a/query.c b/query.c index ea5fc89..df02f4a 100644 --- a/query.c +++ b/query.c @@ -100,11 +100,11 @@ static QUERY *run_query (char *s, int quiet) if (first == NULL) { FirstColumn = 0; SecondColumn = 0; - first = (QUERY *) safe_calloc (1, sizeof (QUERY)); + first = (QUERY *) mem_calloc (1, sizeof (QUERY)); cur = first; } else { - cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY)); + cur->next = (QUERY *) mem_calloc (1, sizeof (QUERY)); cur = cur->next; } @@ -126,7 +126,7 @@ static QUERY *run_query (char *s, int quiet) } } } - FREE (&buf); + mem_free (&buf); fclose (fp); if (mutt_wait_filter (thepid)) { debug_print (1, ("Error: %s\n", msg)); @@ -288,7 +288,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) menu->max++; menu->data = QueryTable = - (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY)); + (ENTRY *) mem_calloc (menu->max, sizeof (ENTRY)); for (i = 0, queryp = results; queryp; queryp = queryp->next, i++) QueryTable[i].data = queryp; @@ -310,14 +310,14 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) queryp = results; while (queryp) { rfc822_free_address (&queryp->addr); - FREE (&queryp->name); - FREE (&queryp->other); + mem_free (&queryp->name); + mem_free (&queryp->other); results = queryp->next; - FREE (&queryp); + mem_free (&queryp); queryp = results; } results = newresults; - FREE (&QueryTable); + mem_free (&QueryTable); } else { /* append */ @@ -345,7 +345,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) if (op == OP_QUERY) { menu->data = QueryTable = - (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY)); + (ENTRY *) mem_calloc (menu->max, sizeof (ENTRY)); for (i = 0, queryp = results; queryp; queryp = queryp->next, i++) @@ -355,7 +355,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) int clear = 0; /* append */ - safe_realloc (&QueryTable, menu->max * sizeof (ENTRY)); + mem_realloc (&QueryTable, menu->max * sizeof (ENTRY)); menu->data = QueryTable; @@ -473,13 +473,13 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) queryp = results; while (queryp) { rfc822_free_address (&queryp->addr); - FREE (&queryp->name); - FREE (&queryp->other); + mem_free (&queryp->name); + mem_free (&queryp->other); results = queryp->next; - FREE (&queryp); + mem_free (&queryp); queryp = results; } - FREE (&QueryTable); + mem_free (&QueryTable); /* tell whoever called me to redraw the screen when I return */ set_option (OPTNEEDREDRAW); diff --git a/recvattach.c b/recvattach.c index 69614ed..265a18c 100644 --- a/recvattach.c +++ b/recvattach.c @@ -56,7 +56,7 @@ static struct mapping_t AttachHelp[] = { int mutt_extract_path (char *filename, char *path) { - char *tmp = safe_malloc (sizeof (char) * _POSIX_PATH_MAX); + char *tmp = mem_malloc (sizeof (char) * _POSIX_PATH_MAX); char *help_ptr; help_ptr = tmp; @@ -70,7 +70,7 @@ int mutt_extract_path (char *filename, char *path) } *help_ptr++ = *filename++; } - FREE (&tmp); + mem_free (&tmp); return 0; } @@ -120,7 +120,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m, for (; m; m = m->next) { if (*idxlen == *idxmax) { - safe_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5)); + mem_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5)); for (i = *idxlen; i < *idxmax; i++) idx[i] = NULL; } @@ -138,7 +138,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m, } else { if (!idx[*idxlen]) - idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); + idx[*idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR)); new = idx[(*idxlen)++]; new->content = m; @@ -527,7 +527,7 @@ void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr, break; } - FREE (&directory); + mem_free (&directory); if (tag && menu) { menu->oldcurrent = menu->current; @@ -1218,12 +1218,12 @@ void mutt_view_attachments (HEADER * hdr) hdr->attach_del = 1; if (idx[idxmax]->content) idx[idxmax]->content->aptr = NULL; - FREE (&idx[idxmax]->tree); - FREE (&idx[idxmax]); + mem_free (&idx[idxmax]->tree); + mem_free (&idx[idxmax]); } if (hdr->attach_del) hdr->changed = 1; - FREE (&idx); + mem_free (&idx); idxmax = 0; if (WithCrypto && need_secured && secured) { diff --git a/recvcmd.c b/recvcmd.c index f7b93d7..e7cad2e 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -149,7 +149,7 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr, if (mutt_addrlist_to_idna (adr, &err) < 0) { mutt_error (_("Bad IDN: '%s'"), err); - FREE (&err); + mem_free (&err); rfc822_free_address (&adr); return; } diff --git a/regex.c b/regex.c index b2755ca..ac6ede9 100644 --- a/regex.c +++ b/regex.c @@ -313,7 +313,7 @@ static void init_syntax_once () #define REGEX_ALLOCATE malloc #define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) -#define REGEX_FREE free +#define REGEX_mem_free free #else /* not REGEX_MALLOC */ @@ -346,7 +346,7 @@ char *alloca (); destination) /* No need to do anything to free, after alloca. */ -#define REGEX_FREE(arg) ((void)0) /* Do nothing! But inhibit gcc warning. */ +#define REGEX_mem_free(arg) ((void)0) /* Do nothing! But inhibit gcc warning. */ #endif /* not REGEX_MALLOC */ @@ -358,7 +358,7 @@ char *alloca (); r_alloc (&failure_stack_ptr, (size)) #define REGEX_REALLOCATE_STACK(source, osize, nsize) \ r_re_alloc (&failure_stack_ptr, (nsize)) -#define REGEX_FREE_STACK(ptr) \ +#define REGEX_mem_free_STACK(ptr) \ r_alloc_free (&failure_stack_ptr) #else /* not using relocating allocator */ @@ -367,7 +367,7 @@ char *alloca (); #define REGEX_ALLOCATE_STACK malloc #define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize) -#define REGEX_FREE_STACK free +#define REGEX_mem_free_STACK free #else /* not REGEX_MALLOC */ @@ -376,7 +376,7 @@ char *alloca (); #define REGEX_REALLOCATE_STACK(source, osize, nsize) \ REGEX_REALLOCATE (source, osize, nsize) /* No need to explicitly free anything. */ -#define REGEX_FREE_STACK(arg) +#define REGEX_mem_free_STACK(arg) #endif /* not REGEX_MALLOC */ #endif /* not using relocating allocator */ @@ -1156,7 +1156,7 @@ typedef struct { fail_stack.avail = 0; \ } while (0) -#define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack) +#define RESET_FAIL_STACK() REGEX_mem_free_STACK (fail_stack.stack) #else #define INIT_FAIL_STACK() \ do { \ @@ -1808,7 +1808,7 @@ static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type examined nor set. */ /* Return, freeing storage we allocated. */ -#define FREE_STACK_RETURN(value) \ +#define mem_free_STACK_RETURN(value) \ return (free (compile_stack.stack), value) /* __MEM_CHECKED__ */ #ifndef HAVE_ISCTYPE @@ -1946,7 +1946,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); } if (!bufp->buffer) - FREE_STACK_RETURN (REG_ESPACE); + mem_free_STACK_RETURN (REG_ESPACE); bufp->allocated = INIT_BUF_SIZE; } @@ -1998,7 +1998,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* If there is no previous pattern... */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) - FREE_STACK_RETURN (REG_BADRPT); + mem_free_STACK_RETURN (REG_BADRPT); else if (!(syntax & RE_CONTEXT_INDEP_OPS)) goto normal_char; } @@ -2029,7 +2029,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) else if (syntax & RE_BK_PLUS_QM && c == '\\') { if (p == pend) - FREE_STACK_RETURN (REG_EESCAPE); + mem_free_STACK_RETURN (REG_EESCAPE); PATFETCH (c1); if (!(c1 == '+' || c1 == '?')) { @@ -2123,7 +2123,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) boolean had_char_class = false; if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); /* Ensure that we have enough space to push a charset: the opcode, the length count, and the bitset; 34 bytes in all. */ @@ -2154,14 +2154,14 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* Read in characters and ranges, setting map bits. */ for (;;) { if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); PATFETCH (c); /* \ might escape characters inside [...] and [^...]. */ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') { if (p == pend) - FREE_STACK_RETURN (REG_EESCAPE); + mem_free_STACK_RETURN (REG_EESCAPE); PATFETCH (c1); SET_LIST_BIT (c1); @@ -2177,7 +2177,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* Look ahead to see if it's a range when the last thing was a character class. */ if (had_char_class && c == '-' && *p != ']') - FREE_STACK_RETURN (REG_ERANGE); + mem_free_STACK_RETURN (REG_ERANGE); /* Look ahead to see if it's a range when the last thing was a character: if this is a hyphen not at the @@ -2189,7 +2189,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) reg_errcode_t ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) - FREE_STACK_RETURN (ret); + mem_free_STACK_RETURN (ret); } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */ @@ -2200,7 +2200,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) - FREE_STACK_RETURN (ret); + mem_free_STACK_RETURN (ret); } /* See if we're at the beginning of a possible character @@ -2214,7 +2214,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* If pattern is `[[:'. */ if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); for (;;) { PATFETCH (c); @@ -2237,14 +2237,14 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) wt = ctype (str); if (wt == 0) - FREE_STACK_RETURN (REG_ECTYPE); + mem_free_STACK_RETURN (REG_ECTYPE); /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); for (ch = 0; ch < 1 << BYTEWIDTH; ++ch) { if (isctype (ch, wt)) @@ -2272,14 +2272,14 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) boolean is_xdigit = STREQ (str, "xdigit"); if (!IS_CHAR_CLASS (str)) - FREE_STACK_RETURN (REG_ECTYPE); + mem_free_STACK_RETURN (REG_ECTYPE); /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { /* This was split into 3 if's to @@ -2367,7 +2367,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) case '\\': if (p == pend) - FREE_STACK_RETURN (REG_EESCAPE); + mem_free_STACK_RETURN (REG_EESCAPE); /* Do not translate the character after the \, so that we can distinguish, e.g., \B from \b, even if we normally would @@ -2431,7 +2431,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) { goto normal_backslash; } else { - FREE_STACK_RETURN (REG_ERPAREN); + mem_free_STACK_RETURN (REG_ERPAREN); } } @@ -2452,7 +2452,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) { goto normal_char; } else { - FREE_STACK_RETURN (REG_ERPAREN); + mem_free_STACK_RETURN (REG_ERPAREN); } } @@ -2558,7 +2558,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else - FREE_STACK_RETURN (REG_EBRACE); + mem_free_STACK_RETURN (REG_EBRACE); } GET_UNSIGNED_NUMBER (lower_bound); @@ -2577,12 +2577,12 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else - FREE_STACK_RETURN (REG_BADBR); + mem_free_STACK_RETURN (REG_BADBR); } if (!(syntax & RE_NO_BK_BRACES)) { if (c != '\\') - FREE_STACK_RETURN (REG_EBRACE); + mem_free_STACK_RETURN (REG_EBRACE); PATFETCH (c); } @@ -2591,7 +2591,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else - FREE_STACK_RETURN (REG_BADBR); + mem_free_STACK_RETURN (REG_BADBR); } /* We just parsed a valid interval. */ @@ -2599,7 +2599,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* If it's invalid to have no preceding re. */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) - FREE_STACK_RETURN (REG_BADRPT); + mem_free_STACK_RETURN (REG_BADRPT); else if (syntax & RE_CONTEXT_INDEP_OPS) laststart = b; else @@ -2783,7 +2783,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) c1 = c - '0'; if (c1 > regnum) - FREE_STACK_RETURN (REG_ESUBREG); + mem_free_STACK_RETURN (REG_ESUBREG); /* Can't back reference to a subexpression if inside of it. */ if (group_in_compile_stack (compile_stack, (regnum_t) c1)) @@ -2850,7 +2850,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); if (!COMPILE_STACK_EMPTY) - FREE_STACK_RETURN (REG_EPAREN); + mem_free_STACK_RETURN (REG_EPAREN); /* If we don't want backtracking, force success the first time we reach the end of the compiled pattern. */ @@ -3634,22 +3634,22 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, /* Free everything we malloc. */ #ifdef MATCH_MAY_ALLOCATE -#define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL -#define FREE_VARIABLES() \ +#define mem_free_VAR(var) if (var) REGEX_mem_free (var); var = NULL +#define mem_free_VARIABLES() \ do { \ - REGEX_FREE_STACK (fail_stack.stack); \ - FREE_VAR (regstart); \ - FREE_VAR (regend); \ - FREE_VAR (old_regstart); \ - FREE_VAR (old_regend); \ - FREE_VAR (best_regstart); \ - FREE_VAR (best_regend); \ - FREE_VAR (reg_info); \ - FREE_VAR (reg_dummy); \ - FREE_VAR (reg_info_dummy); \ + REGEX_mem_free_STACK (fail_stack.stack); \ + mem_free_VAR (regstart); \ + mem_free_VAR (regend); \ + mem_free_VAR (old_regstart); \ + mem_free_VAR (old_regend); \ + mem_free_VAR (best_regstart); \ + mem_free_VAR (best_regend); \ + mem_free_VAR (reg_info); \ + mem_free_VAR (reg_dummy); \ + mem_free_VAR (reg_info_dummy); \ } while (0) #else -#define FREE_VARIABLES() ((void)0) /* Do nothing! But inhibit gcc warning. */ +#define mem_free_VARIABLES() ((void)0) /* Do nothing! But inhibit gcc warning. */ #endif /* not MATCH_MAY_ALLOCATE */ /* These values must meet several constraints. They must not be valid @@ -3887,13 +3887,13 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) if (!(regstart && regend && old_regstart && old_regend && reg_info && best_regstart && best_regend && reg_dummy && reg_info_dummy)) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -2; } } else { /* We must initialize all our variables to NULL, so that - `FREE_VARIABLES' doesn't try to free them. */ + `mem_free_VARIABLES' doesn't try to free them. */ regstart = regend = old_regstart = old_regend = best_regstart = best_regend = reg_dummy = NULL; reg_info = reg_info_dummy = (register_info_type *) NULL; @@ -3902,7 +3902,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) /* The starting position is bogus. */ if (pos < 0 || pos > size1 + size2) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -1; } @@ -4047,7 +4047,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) regs->start = TALLOC (regs->num_regs, regoff_t); regs->end = TALLOC (regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -2; } bufp->regs_allocated = REGS_REALLOCATE; @@ -4060,7 +4060,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) RETALLOC (regs->start, regs->num_regs, regoff_t); RETALLOC (regs->end, regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -2; } } @@ -4113,7 +4113,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); - FREE_VARIABLES (); + mem_free_VARIABLES (); return mcnt; } @@ -5054,7 +5054,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) if (best_regs_set) goto restore_best_regs; - FREE_VARIABLES (); + mem_free_VARIABLES (); return -1; /* Failure to match. */ } /* re_match_2 */ diff --git a/remailer.c b/remailer.c index 783ee59..7825407 100644 --- a/remailer.c +++ b/remailer.c @@ -100,7 +100,7 @@ static void mix_add_entry (REMAILER *** type2_list, REMAILER * entry, { if (*used == *slots) { *slots += 5; - safe_realloc (type2_list, sizeof (REMAILER *) * (*slots)); + mem_realloc (type2_list, sizeof (REMAILER *) * (*slots)); } (*type2_list)[(*used)++] = entry; @@ -110,16 +110,16 @@ static void mix_add_entry (REMAILER *** type2_list, REMAILER * entry, static REMAILER *mix_new_remailer (void) { - return safe_calloc (1, sizeof (REMAILER)); + return mem_calloc (1, sizeof (REMAILER)); } static void mix_free_remailer (REMAILER ** r) { - FREE (&(*r)->shortname); - FREE (&(*r)->addr); - FREE (&(*r)->ver); + mem_free (&(*r)->shortname); + mem_free (&(*r)->addr); + mem_free (&(*r)->ver); - FREE (r); + mem_free (r); } /* parse the type2.list as given by mixmaster -T */ @@ -209,7 +209,7 @@ static void mix_free_type2_list (REMAILER *** ttlp) for (i = 0; type2_list[i]; i++) mix_free_remailer (&type2_list[i]); - FREE (type2_list); + mem_free (type2_list); } @@ -228,7 +228,7 @@ static void mix_screen_coordinates (REMAILER ** type2_list, if (!chain->cl) return; - safe_realloc (coordsp, sizeof (struct coord) * chain->cl); + mem_realloc (coordsp, sizeof (struct coord) * chain->cl); coords = *coordsp; @@ -490,7 +490,7 @@ void mix_make_chain (LIST ** chainp, int *redraw) *redraw = REDRAW_FULL; - chain = safe_calloc (sizeof (MIXCHAIN), 1); + chain = mem_calloc (sizeof (MIXCHAIN), 1); for (p = *chainp; p; p = p->next) mix_chain_add (chain, (char *) p->data, type2_list); @@ -657,8 +657,8 @@ void mix_make_chain (LIST ** chainp, int *redraw) } mix_free_type2_list (&type2_list); - FREE (&coords); - FREE (&chain); + mem_free (&coords); + mem_free (&chain); } /* some safety checks before piping the message to mixmaster */ diff --git a/rfc1524.c b/rfc1524.c index 6b5eeae..7d54477 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -266,13 +266,13 @@ static int rfc1524_mailcap_parse (BODY * a, if (get_field_text (field + 4, &test_command, type, filename, line) && test_command) { len = str_len (test_command) + STRING; - safe_realloc (&test_command, len); + mem_realloc (&test_command, len); rfc1524_expand_command (a, a->filename, type, test_command, len); if (mutt_system (test_command)) { /* a non-zero exit code means test failed */ found = FALSE; } - FREE (&test_command); + mem_free (&test_command); } } } /* while (ch) */ @@ -297,13 +297,13 @@ static int rfc1524_mailcap_parse (BODY * a, if (!found) { /* reset */ if (entry) { - FREE (&entry->command); - FREE (&entry->composecommand); - FREE (&entry->composetypecommand); - FREE (&entry->editcommand); - FREE (&entry->printcommand); - FREE (&entry->nametemplate); - FREE (&entry->convert); + mem_free (&entry->command); + mem_free (&entry->composecommand); + mem_free (&entry->composetypecommand); + mem_free (&entry->editcommand); + mem_free (&entry->printcommand); + mem_free (&entry->nametemplate); + mem_free (&entry->convert); entry->needsterminal = 0; entry->copiousoutput = 0; } @@ -311,27 +311,27 @@ static int rfc1524_mailcap_parse (BODY * a, } /* while (!found && (buf = mutt_read_line ())) */ fclose (fp); } /* if ((fp = fopen ())) */ - FREE (&buf); + mem_free (&buf); return found; } rfc1524_entry *rfc1524_new_entry (void) { - return (rfc1524_entry *) safe_calloc (1, sizeof (rfc1524_entry)); + return (rfc1524_entry *) mem_calloc (1, sizeof (rfc1524_entry)); } void rfc1524_free_entry (rfc1524_entry ** entry) { rfc1524_entry *p = *entry; - FREE (&p->command); - FREE (&p->testcommand); - FREE (&p->composecommand); - FREE (&p->composetypecommand); - FREE (&p->editcommand); - FREE (&p->printcommand); - FREE (&p->nametemplate); - FREE (entry); + mem_free (&p->command); + mem_free (&p->testcommand); + mem_free (&p->composecommand); + mem_free (&p->composetypecommand); + mem_free (&p->editcommand); + mem_free (&p->printcommand); + mem_free (&p->nametemplate); + mem_free (entry); } /* diff --git a/rfc2047.c b/rfc2047.c index 333667c..69b884f 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -60,11 +60,11 @@ static size_t convert_string (ICONV_CONST char *f, size_t flen, if (cd == (iconv_t) (-1)) return (size_t) (-1); obl = 4 * flen + 1; - ob = buf = safe_malloc (obl); + ob = buf = mem_malloc (obl); n = iconv (cd, &f, &flen, &ob, &obl); if (n == (size_t) (-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t) (-1)) { e = errno; - FREE (&buf); + mem_free (&buf); iconv_close (cd); errno = e; return (size_t) (-1); @@ -73,7 +73,7 @@ static size_t convert_string (ICONV_CONST char *f, size_t flen, *tlen = ob - buf; - safe_realloc (&buf, ob - buf + 1); + mem_realloc (&buf, ob - buf + 1); *t = buf; iconv_close (cd); @@ -102,7 +102,7 @@ char *mutt_choose_charset (const char *fromcode, const char *charsets, n > (ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 2 - 12)) continue; - t = safe_malloc (n + 1); + t = mem_malloc (n + 1); memcpy (t, p, n); t[n] = '\0'; @@ -112,21 +112,21 @@ char *mutt_choose_charset (const char *fromcode, const char *charsets, if (!tocode || n < bestn) { bestn = n; - FREE (&tocode); + mem_free (&tocode); tocode = t; if (d) { - FREE (&e); + mem_free (&e); e = s; } else - FREE (&s); + mem_free (&s); elen = slen; if (!bestn) break; } else { - FREE (&t); - FREE (&s); + mem_free (&t); + mem_free (&s); } } if (tocode) { @@ -361,7 +361,7 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col, if (convert_string (d, dlen, fromcode, icode, &u, &ulen)) { ret = 1; icode = 0; - u = safe_malloc ((ulen = dlen) + 1); + u = mem_malloc ((ulen = dlen) + 1); memcpy (u, d, dlen); u[ulen] = 0; } @@ -446,7 +446,7 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col, /* Initialise the output buffer with the us-ascii prefix. */ buflen = 2 * ulen; - buf = safe_malloc (buflen); + buf = mem_malloc (buflen); bufpos = t0 - u; memcpy (buf, u, t0 - u); @@ -482,7 +482,7 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col, #define LINEBREAK "\n\t" if (bufpos + wlen + str_len (LINEBREAK) > buflen) { buflen = bufpos + wlen + str_len (LINEBREAK); - safe_realloc (&buf, buflen); + mem_realloc (&buf, buflen); } r = encode_block (buf + bufpos, t, n, icode, tocode, encoder); assert (r == wlen); @@ -498,14 +498,14 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col, /* Add last encoded word and us-ascii suffix to buffer. */ buflen = bufpos + wlen + (u + ulen - t1); - safe_realloc (&buf, buflen + 1); + mem_realloc (&buf, buflen + 1); r = encode_block (buf + bufpos, t, t1 - t, icode, tocode, encoder); assert (r == wlen); bufpos += wlen; memcpy (buf + bufpos, t1, u + ulen - t1); - FREE (&tocode1); - FREE (&u); + mem_free (&tocode1); + mem_free (&u); buf[buflen] = '\0'; @@ -531,7 +531,7 @@ void _rfc2047_encode_string (char **pd, int encode_specials, int col) Charset, charsets, &e, &elen, encode_specials ? RFC822Specials : NULL); - FREE (pd); + mem_free (pd); *pd = e; } @@ -555,7 +555,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) int enc = 0, count = 0; char *charset = NULL; - pd = d0 = safe_malloc (str_len (s)); + pd = d0 = mem_malloc (str_len (s)); for (pp = s; (pp1 = strchr (pp, '?')); pp = pp1 + 1) { count++; @@ -565,7 +565,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) t = pp1; if ((t1 = memchr (pp, '*', t - pp))) t = t1; - charset = safe_malloc (t - pp + 1); + charset = mem_malloc (t - pp + 1); memcpy (charset, pp, t - pp); charset[t - pp] = '\0'; break; @@ -575,8 +575,8 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) else if (toupper ((unsigned char) *pp) == 'B') enc = ENCBASE64; else { - FREE (&charset); - FREE (&d0); + mem_free (&charset); + mem_free (&d0); return (-1); } break; @@ -623,8 +623,8 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) if (charset) mutt_convert_string (&d0, charset, Charset, M_ICONV_HOOK_FROM); strfcpy (d, d0, len); - FREE (&charset); - FREE (&d0); + mem_free (&charset); + mem_free (&d0); return (0); } @@ -712,7 +712,7 @@ void rfc2047_decode (char **pd) return; dlen = 4 * str_len (s); /* should be enough */ - d = d0 = safe_malloc (dlen + 1); + d = d0 = mem_malloc (dlen + 1); while (*s && dlen > 0) { if (!(p = find_encoded_word (s, &q))) { @@ -728,7 +728,7 @@ void rfc2047_decode (char **pd) char *t; size_t tlen; - t = safe_malloc (n + 1); + t = mem_malloc (n + 1); strfcpy (t, s, n + 1); if (mutt_convert_nonmime_string (&t) == 0) { tlen = str_len (t); @@ -739,7 +739,7 @@ void rfc2047_decode (char **pd) strncpy (d, s, n); d += n; } - FREE (&t); + mem_free (&t); break; } } @@ -787,7 +787,7 @@ void rfc2047_decode (char **pd) } *d = 0; - FREE (pd); + mem_free (pd); *pd = d0; str_adjust (pd); } diff --git a/rfc2231.c b/rfc2231.c index f7caea1..6c9d4b5 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -145,7 +145,7 @@ void rfc2231_decode_parameters (PARAMETER ** headp) p->attribute = NULL; p->value = NULL; - FREE (&p); + mem_free (&p); rfc2231_list_insert (&conthead, conttmp); } @@ -164,15 +164,15 @@ void rfc2231_decode_parameters (PARAMETER ** headp) static struct rfc2231_parameter *rfc2231_new_parameter (void) { - return safe_calloc (sizeof (struct rfc2231_parameter), 1); + return mem_calloc (sizeof (struct rfc2231_parameter), 1); } static void rfc2231_free_parameter (struct rfc2231_parameter **p) { if (*p) { - FREE (&(*p)->attribute); - FREE (&(*p)->value); - FREE (p); + mem_free (&(*p)->attribute); + mem_free (&(*p)->value); + mem_free (p); } } @@ -271,7 +271,7 @@ static void rfc2231_join_continuations (PARAMETER ** head, vl = str_len (par->value); - safe_realloc (&value, l + vl + 1); + mem_realloc (&value, l + vl + 1); strcpy (value + l, par->value); /* __STRCPY_CHECKED__ */ l += vl; @@ -330,7 +330,7 @@ int rfc2231_encode_string (char **pd) ++ext; if (encode) { - e = safe_malloc (dlen + 2 * ext + str_len (charset) + 3); + e = mem_malloc (dlen + 2 * ext + str_len (charset) + 3); sprintf (e, "%s''", charset); /* __SPRINTF_CHECKED__ */ t = e + str_len (e); for (s = d, slen = dlen; slen; s++, slen--) @@ -344,16 +344,16 @@ int rfc2231_encode_string (char **pd) *t = '\0'; if (d != *pd) - FREE (&d); - FREE (pd); + mem_free (&d); + mem_free (pd); *pd = e; } else if (d != *pd) { - FREE (pd); + mem_free (pd); *pd = d; } - FREE (&charset); + mem_free (&charset); return encode; } diff --git a/rfc822.c b/rfc822.c index 618e37b..32dcd7b 100644 --- a/rfc822.c +++ b/rfc822.c @@ -70,9 +70,9 @@ void rfc822_free_address (ADDRESS ** p) while (*p) { t = *p; *p = (*p)->next; - FREE (&t->personal); - FREE (&t->mailbox); - FREE (&t); + mem_free (&t->personal); + mem_free (&t->mailbox); + mem_free (&t); } } @@ -389,7 +389,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s) cur = rfc822_new_address (); if (phraselen) { if (cur->personal) - FREE (&cur->personal); + mem_free (&cur->personal); /* if we get something like "Michael R. Elkins" remove the quotes */ rfc822_dequote_comment (phrase); cur->personal = str_dup (phrase); @@ -446,9 +446,9 @@ void rfc822_qualify (ADDRESS * addr, const char *host) for (; addr; addr = addr->next) if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL) { - p = safe_malloc (str_len (addr->mailbox) + str_len (host) + 2); + p = mem_malloc (str_len (addr->mailbox) + str_len (host) + 2); sprintf (p, "%s@%s", addr->mailbox, host); /* __SPRINTF_CHECKED__ */ - FREE (&addr->mailbox); + mem_free (&addr->mailbox); addr->mailbox = p; } } diff --git a/score.c b/score.c index 1c442ec..380283e 100644 --- a/score.c +++ b/score.c @@ -70,7 +70,7 @@ int mutt_parse_score (BUFFER * buf, BUFFER * s, unsigned long data, memset (buf, 0, sizeof (BUFFER)); mutt_extract_token (buf, s, 0); if (MoreArgs (s)) { - FREE (&pattern); + mem_free (&pattern); strfcpy (err->data, _("score: too many arguments"), err->dsize); return (-1); } @@ -82,10 +82,10 @@ int mutt_parse_score (BUFFER * buf, BUFFER * s, unsigned long data, break; if (!ptr) { if ((pat = mutt_pattern_comp (pattern, 0, err)) == NULL) { - FREE (&pattern); + mem_free (&pattern); return (-1); } - ptr = safe_calloc (1, sizeof (SCORE)); + ptr = mem_calloc (1, sizeof (SCORE)); if (last) last->next = ptr; else @@ -140,7 +140,7 @@ int mutt_parse_unscore (BUFFER * buf, BUFFER * s, unsigned long data, last = tmp; tmp = tmp->next; mutt_pattern_free (&last->pat); - FREE (&last); + mem_free (&last); } Score = NULL; } @@ -152,7 +152,7 @@ int mutt_parse_unscore (BUFFER * buf, BUFFER * s, unsigned long data, else Score = tmp->next; mutt_pattern_free (&tmp->pat); - FREE (&tmp); + mem_free (&tmp); /* there should only be one score per pattern, so we can stop here */ break; } diff --git a/send.c b/send.c index fd4bf77..704b53b 100644 --- a/send.c +++ b/send.c @@ -192,7 +192,7 @@ static int edit_address (ADDRESS ** a, /* const */ char *field) mutt_error (_("Error: '%s' is a bad IDN."), err); mutt_refresh (); mutt_sleep (2); - FREE (&err); + mem_free (&err); } } while (idna_ok != 0); @@ -213,7 +213,7 @@ static int edit_envelope (ENVELOPE * en, int flags) buf[0] = 0; if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0) return (-1); - FREE (&en->newsgroups); + mem_free (&en->newsgroups); en->newsgroups = str_dup (buf); if (en->followup_to) @@ -223,7 +223,7 @@ static int edit_envelope (ENVELOPE * en, int flags) if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0) return (-1); - FREE (&en->followup_to); + mem_free (&en->followup_to); en->followup_to = str_dup (buf); if (en->x_comment_to) @@ -233,7 +233,7 @@ static int edit_envelope (ENVELOPE * en, int flags) if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0) return (-1); - FREE (&en->x_comment_to); + mem_free (&en->x_comment_to); en->x_comment_to = str_dup (buf); } else @@ -373,7 +373,7 @@ LIST *mutt_copy_list (LIST * p) LIST *t, *r = NULL, *l = NULL; for (; p; p = p->next) { - t = (LIST *) safe_malloc (sizeof (LIST)); + t = (LIST *) mem_malloc (sizeof (LIST)); t->data = str_dup (p->data); t->next = NULL; if (l) { @@ -659,8 +659,8 @@ void mutt_make_misc_reply_headers (ENVELOPE * env, CONTEXT * ctx, * been taken from a List-Post header. Is that correct? */ if (curenv->real_subj) { - FREE (&env->subject); - env->subject = safe_malloc (str_len (curenv->real_subj) + 5); + mem_free (&env->subject); + env->subject = mem_malloc (str_len (curenv->real_subj) + 5); sprintf (env->subject, "Re: %s", curenv->real_subj); /* __SPRINTF_CHECKED__ */ } else if (!env->subject) @@ -974,7 +974,7 @@ static ADDRESS *set_reverse_name (ENVELOPE * env) if (tmp) { tmp = rfc822_cpy_adr_real (tmp); if (!option (OPTREVREAL)) - FREE (&tmp->personal); + mem_free (&tmp->personal); if (!tmp->personal) tmp->personal = str_dup (Realname); } @@ -996,7 +996,7 @@ ADDRESS *mutt_default_from (void) else if (option (OPTUSEDOMAIN)) { adr = rfc822_new_address (); adr->mailbox = - safe_malloc (str_len (Username) + str_len (fqdn) + 2); + mem_malloc (str_len (Username) + str_len (fqdn) + 2); sprintf (adr->mailbox, "%s@%s", NONULL (Username), NONULL (fqdn)); /* __SPRINTF_CHECKED__ */ } else { @@ -1556,7 +1556,7 @@ int ci_send_message (int flags, /* send mode */ if (mutt_env_to_idna (msg->env, &tag, &err)) { mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err); - FREE (&err); + mem_free (&err); if (!(flags & SENDBATCH)) goto main_loop; else @@ -1617,7 +1617,7 @@ int ci_send_message (int flags, /* send mode */ mutt_protect (msg, pgpkeylist) == -1) { msg->content = mutt_remove_multipart (msg->content); - FREE (&pgpkeylist); + mem_free (&pgpkeylist); decode_descriptions (msg->content); goto main_loop; @@ -1781,7 +1781,7 @@ int ci_send_message (int flags, /* send mode */ #endif if (WithCrypto && (msg->security & ENCRYPT)) - FREE (&pgpkeylist); + mem_free (&pgpkeylist); if (WithCrypto && free_clear_content) mutt_free_body (&clear_content); @@ -1803,7 +1803,7 @@ cleanup: if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED)) { if (signas) { - FREE (&PgpSignAs); + mem_free (&PgpSignAs); PgpSignAs = signas; } } diff --git a/sendlib.c b/sendlib.c index 629e197..80790f4 100644 --- a/sendlib.c +++ b/sendlib.c @@ -315,7 +315,7 @@ int mutt_write_mime_header (BODY * a, FILE * f) && !strcmp (buffer, tmp)) snprintf (buffer, sizeof (buffer), "\"%s\"", tmp); - FREE (&tmp); + mem_free (&tmp); tmplen = str_len (buffer) + str_len (p->attribute) + 1; @@ -357,7 +357,7 @@ int mutt_write_mime_header (BODY * a, FILE * f) tmp = str_dup (t); encode = rfc2231_encode_string (&tmp); rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials); - FREE (&tmp); + mem_free (&tmp); fprintf (f, "; filename%s=%s", encode ? "*" : "", buffer); } } @@ -613,10 +613,10 @@ static size_t convert_file_to (FILE * file, const char *fromcode, if (cd1 == (iconv_t) (-1)) return -1; - cd = safe_calloc (ncodes, sizeof (iconv_t)); - score = safe_calloc (ncodes, sizeof (size_t)); - states = safe_calloc (ncodes, sizeof (CONTENT_STATE)); - infos = safe_calloc (ncodes, sizeof (CONTENT)); + cd = mem_calloc (ncodes, sizeof (iconv_t)); + score = mem_calloc (ncodes, sizeof (size_t)); + states = mem_calloc (ncodes, sizeof (CONTENT_STATE)); + infos = mem_calloc (ncodes, sizeof (CONTENT)); for (i = 0; i < ncodes; i++) if (ascii_strcasecmp (tocodes[i], "UTF-8")) @@ -706,10 +706,10 @@ static size_t convert_file_to (FILE * file, const char *fromcode, iconv_close (cd[i]); iconv_close (cd1); - FREE (&cd); - FREE (&infos); - FREE (&score); - FREE (&states); + mem_free (&cd); + mem_free (&infos); + mem_free (&score); + mem_free (&states); return ret; #else @@ -748,7 +748,7 @@ static size_t convert_file_from_to (FILE * file, } /* Copy them */ - tcode = safe_malloc (ncodes * sizeof (char *)); + tcode = mem_malloc (ncodes * sizeof (char *)); for (c = tocodes, i = 0; c; c = c1 ? c1 + 1 : 0, i++) { if ((c1 = strchr (c, ':')) == c) continue; @@ -771,7 +771,7 @@ static size_t convert_file_from_to (FILE * file, tcode[cn] = 0; break; } - FREE (&fcode); + mem_free (&fcode); } } else { @@ -786,9 +786,9 @@ static size_t convert_file_from_to (FILE * file, /* Free memory */ for (i = 0; i < ncodes; i++) - FREE (&tcode[i]); + mem_free (&tcode[i]); - FREE (tcode); + mem_free (tcode); return ret; } @@ -828,7 +828,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY * b) return (NULL); } - info = safe_calloc (1, sizeof (CONTENT)); + info = mem_calloc (1, sizeof (CONTENT)); memset (&state, 0, sizeof (state)); if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset)) { @@ -843,7 +843,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY * b) mutt_set_parameter ("charset", chsbuf, &b->parameter); } b->file_charset = fromcode; - FREE (&tocode); + mem_free (&tocode); safe_fclose (&fp); return info; } @@ -1015,7 +1015,7 @@ void mutt_message_to_7bit (BODY * a, FILE * fp) mutt_write_mime_body (a->parts, fpout); cleanup: - FREE (&line); + mem_free (&line); if (fpin && !fp) fclose (fpin); @@ -1179,7 +1179,7 @@ void mutt_update_encoding (BODY * a) mutt_set_encoding (a, info); mutt_stamp_attachment (a); - FREE (&a->content); + mem_free (&a->content); a->content = info; } @@ -1433,7 +1433,7 @@ void mutt_write_references (LIST * r, FILE * f) for (; (TrimRef == 0 || refcnt < TrimRef) && r; r = r->next) { if (refcnt == refmax) - safe_realloc (&ref, (refmax += REF_INC) * sizeof (LIST *)); + mem_realloc (&ref, (refmax += REF_INC) * sizeof (LIST *)); ref[refcnt++] = r; } @@ -1442,7 +1442,7 @@ void mutt_write_references (LIST * r, FILE * f) fputs (ref[refcnt]->data, f); } - FREE (&ref); + mem_free (&ref); } /* Note: all RFC2047 encoding should be done outside of this routine, except @@ -1637,12 +1637,12 @@ static void encode_headers (LIST * h) continue; rfc2047_encode_string (&tmp); - safe_realloc (&h->data, + mem_realloc (&h->data, str_len (h->data) + 2 + str_len (tmp) + 1); sprintf (h->data + i, ": %s", NONULL (tmp)); /* __SPRINTF_CHECKED__ */ - FREE (&tmp); + mem_free (&tmp); } } @@ -1869,7 +1869,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) } else if (pid == -1) { unlink (msg); - FREE (tempfile); + mem_free (tempfile); _exit (S_ERR); } @@ -1897,14 +1897,14 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) st = WIFEXITED (st) ? WEXITSTATUS (st) : S_ERR; if (SendmailWait && st == (0xff & EX_OK)) { unlink (*tempfile); /* no longer needed */ - FREE (tempfile); + mem_free (tempfile); } } else { st = (SendmailWait > 0 && errno == EINTR && SigAlrm) ? S_BKG : S_ERR; if (SendmailWait > 0) { unlink (*tempfile); - FREE (tempfile); + mem_free (tempfile); } } @@ -1915,7 +1915,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) if (kill (ppid, 0) == -1 && errno == ESRCH) { /* the parent is already dead */ unlink (*tempfile); - FREE (tempfile); + mem_free (tempfile); } _exit (st); @@ -1940,7 +1940,7 @@ static char **add_args (char **args, size_t * argslen, size_t * argsmax, /* weed out group mailboxes, since those are for display only */ if (addr->mailbox && !addr->group) { if (*argslen == *argsmax) - safe_realloc (&args, (*argsmax += 5) * sizeof (char *)); + mem_realloc (&args, (*argsmax += 5) * sizeof (char *)); args[(*argslen)++] = addr->mailbox; } } @@ -1951,7 +1951,7 @@ static char **add_option (char **args, size_t * argslen, size_t * argsmax, char *s) { if (*argslen == *argsmax) - safe_realloc (&args, (*argsmax += 5) * sizeof (char *)); + mem_realloc (&args, (*argsmax += 5) * sizeof (char *)); args[(*argslen)++] = s; return (args); } @@ -1988,7 +1988,7 @@ static int mutt_invoke_sendmail (ADDRESS * from, /* the sender */ i = 0; while ((ps = strtok (ps, " "))) { if (argslen == argsmax) - safe_realloc (&args, sizeof (char *) * (argsmax += 5)); + mem_realloc (&args, sizeof (char *) * (argsmax += 5)); if (i) args[argslen++] = ps; @@ -2032,7 +2032,7 @@ static int mutt_invoke_sendmail (ADDRESS * from, /* the sender */ #endif if (argslen == argsmax) - safe_realloc (&args, sizeof (char *) * (++argsmax)); + mem_realloc (&args, sizeof (char *) * (++argsmax)); args[argslen++] = NULL; @@ -2055,10 +2055,10 @@ static int mutt_invoke_sendmail (ADDRESS * from, /* the sender */ else unlink (childout); - FREE (&childout); - FREE (&path); - FREE (&s); - FREE (&args); + mem_free (&childout); + mem_free (&path); + mem_free (&s); + mem_free (&args); if (i == (EX_OK & 0xff)) i = 0; @@ -2088,7 +2088,7 @@ char *mutt_append_string (char *a, const char *b) { size_t la = str_len (a); - safe_realloc (&a, la + str_len (b) + 1); + mem_realloc (&a, la + str_len (b) + 1); strcpy (a + la, b); /* __STRCPY_CHECKED__ */ return (a); } @@ -2117,13 +2117,13 @@ char *mutt_quote_string (const char *s) size_t rlen; rlen = str_len (s) + 3; - pr = r = (char *) safe_malloc (rlen); + pr = r = (char *) mem_malloc (rlen); *pr++ = '"'; while (*s) { if (INVALID_CHAR (*s)) { size_t o = pr - r; - safe_realloc (&r, ++rlen); + mem_realloc (&r, ++rlen); pr = r + o; *pr++ = '\\'; } diff --git a/sidebar.c b/sidebar.c index 5df3fd8..bdfcd6d 100644 --- a/sidebar.c +++ b/sidebar.c @@ -79,7 +79,7 @@ static char *shortened_hierarchy (char *box, int maxlen) if (last_dot) { ++last_dot; - new_box = safe_malloc (maxlen + 1); + new_box = mem_malloc (maxlen + 1); new_box[0] = box[0]; for (i = 1, j = 1; j < maxlen && i < len; ++i) { if (strchr (SidebarBoundary, box[i])) { @@ -225,7 +225,7 @@ int make_sidebar_entry (char* box, int idx, size_t len) addnstr (entry, len); if (shortened) - FREE(&box); + mem_free(&box); return (1); } diff --git a/smime.c b/smime.c index ece2fd8..0116684 100644 --- a/smime.c +++ b/smime.c @@ -387,7 +387,7 @@ char *smime_ask_for_key (char *prompt, char *mailbox, short public) } /* Read Entries */ cur = 0; - Table = safe_calloc (cert_num, sizeof (smime_id)); + Table = mem_calloc (cert_num, sizeof (smime_id)); while (!feof (index)) { numFields = fscanf (index, MUTT_FORMAT (STRING) " %x.%i " MUTT_FORMAT (STRING), @@ -453,14 +453,14 @@ char *smime_ask_for_key (char *prompt, char *mailbox, short public) } } if (hash) { - fname = safe_malloc (13); /* Hash + '.' + Suffix + \0 */ + fname = mem_malloc (13); /* Hash + '.' + Suffix + \0 */ sprintf (fname, "%.8x.%i", Table[cur].hash, Table[cur].suffix); } else fname = NULL; mutt_menuDestroy (&menu); - FREE (&Table); + mem_free (&Table); set_option (OPTNEEDREDRAW); if (fname) @@ -647,7 +647,7 @@ void _smime_getkeys (char *mailbox) /* the key used last time. */ if (*SmimeKeyToUse && !str_casecmp (k, SmimeKeyToUse + str_len (SmimeKeys) + 1)) { - FREE (&k); + mem_free (&k); return; } else @@ -662,7 +662,7 @@ void _smime_getkeys (char *mailbox) if (str_casecmp (k, SmimeDefaultKey)) smime_void_passphrase (); - FREE (&k); + mem_free (&k); return; } @@ -764,14 +764,14 @@ char *smime_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc) } if (!keyID) { mutt_message (_("No (valid) certificate found for %s."), q->mailbox); - FREE (&keylist); + mem_free (&keylist); rfc822_free_address (&tmp); rfc822_free_address (&addr); return NULL; } keylist_size += str_len (keyID) + 2; - safe_realloc (&keylist, keylist_size); + mem_realloc (&keylist, keylist_size); sprintf (keylist + keylist_used, "%s\n", keyID); /* __SPRINTF_CHECKED__ */ keylist_used = str_len (keylist); @@ -852,13 +852,13 @@ static int smime_handle_cert_email (char *certificate, char *mailbox, if (copy && buffer && num) { (*num) = count; - *buffer = safe_calloc (sizeof (char *), count); + *buffer = mem_calloc (sizeof (char *), count); count = 0; rewind (fpout); while ((fgets (email, sizeof (email), fpout))) { *(email + str_len (email) - 1) = '\0'; - (*buffer)[count] = safe_calloc (1, str_len (email) + 1); + (*buffer)[count] = mem_calloc (1, str_len (email) + 1); strncpy ((*buffer)[count], email, str_len (email)); count++; } @@ -1089,7 +1089,7 @@ void smime_invoke_import (char *infile, char *mailbox) mutt_wait_filter (thepid); mutt_unlink (certfile); - FREE (&certfile); + mem_free (&certfile); } fflush (fpout); @@ -1148,7 +1148,7 @@ int smime_verify_sender (HEADER * h) else retval = 0; mutt_unlink (certfile); - FREE (&certfile); + mem_free (&certfile); } else mutt_any_key_to_continue (_("no certfile")); @@ -1565,7 +1565,7 @@ int smime_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) if (linelen && !str_casecmp (line, "verification successful")) badsig = 0; - FREE (&line); + mem_free (&line); } } @@ -1778,7 +1778,7 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile) line = mutt_read_line (line, &linelen, smimeerr, &lineno); if (linelen && !str_casecmp (line, "verification successful")) m->goodsig = 1; - FREE (&line); + mem_free (&line); } else { m->goodsig = p->goodsig; diff --git a/thread.c b/thread.c index 1ca956a..bdd676e 100644 --- a/thread.c +++ b/thread.c @@ -128,7 +128,7 @@ static void calculate_visibility (CONTEXT * ctx, int *max_depth) tree->subtree_visible = 0; if (tree->message) { - FREE (&tree->message->tree); + mem_free (&tree->message->tree); if (VISIBLE (tree->message, ctx)) { tree->deep = 1; tree->visible = 1; @@ -220,8 +220,8 @@ void mutt_draw_tree (CONTEXT * ctx) * From now on we can simply ignore invisible subtrees */ calculate_visibility (ctx, &max_depth); - pfx = safe_malloc (width * max_depth + 2); - arrow = safe_malloc (width * max_depth + 2); + pfx = mem_malloc (width * max_depth + 2); + arrow = mem_malloc (width * max_depth + 2); while (tree) { if (depth) { myarrow = arrow + (depth - start_depth - (start_depth ? 0 : 1)) * width; @@ -239,7 +239,7 @@ void mutt_draw_tree (CONTEXT * ctx) if (tree->visible) { myarrow[width] = M_TREE_RARROW; myarrow[width + 1] = 0; - new_tree = safe_malloc ((2 + depth * width)); + new_tree = mem_malloc ((2 + depth * width)); if (start_depth > 1) { strncpy (new_tree, pfx, (start_depth - 1) * width); strfcpy (new_tree + (start_depth - 1) * width, @@ -306,8 +306,8 @@ void mutt_draw_tree (CONTEXT * ctx) while (!tree->deep); } - FREE (&pfx); - FREE (&arrow); + mem_free (&pfx); + mem_free (&arrow); } /* since we may be trying to attach as a pseudo-thread a THREAD that @@ -343,7 +343,7 @@ static LIST *make_subject_list (THREAD * cur, time_t * dateptr) break; } if (!curlist || rc > 0) { - newlist = safe_calloc (1, sizeof (LIST)); + newlist = mem_calloc (1, sizeof (LIST)); newlist->data = env->real_subj; if (oldlist) { newlist->next = oldlist->next; @@ -404,7 +404,7 @@ static THREAD *find_subject (CONTEXT * ctx, THREAD * cur) oldlist = subjects; subjects = subjects->next; - FREE (&oldlist); + mem_free (&oldlist); } return (last); } @@ -546,7 +546,7 @@ THREAD *mutt_sort_subthreads (THREAD * thread, int init) top = thread; - array = safe_calloc ((array_size = 256), sizeof (THREAD *)); + array = mem_calloc ((array_size = 256), sizeof (THREAD *)); while (1) { if (init || !thread->sort_key) { thread->sort_key = NULL; @@ -578,7 +578,7 @@ THREAD *mutt_sort_subthreads (THREAD * thread, int init) /* put them into the array */ for (i = 0; thread; i++, thread = thread->prev) { if (i >= array_size) - safe_realloc (&array, (array_size *= 2) * sizeof (THREAD *)); + mem_realloc (&array, (array_size *= 2) * sizeof (THREAD *)); array[i] = thread; } @@ -638,7 +638,7 @@ THREAD *mutt_sort_subthreads (THREAD * thread, int init) } else { Sort ^= SORT_REVERSE; - FREE (&array); + mem_free (&array); return (top); } } @@ -755,7 +755,7 @@ void mutt_sort_threads (CONTEXT * ctx, int init) else { new = (option (OPTDUPTHREADS) ? thread : NULL); - thread = safe_calloc (1, sizeof (THREAD)); + thread = mem_calloc (1, sizeof (THREAD)); thread->message = cur; thread->check_subject = 1; cur->thread = thread; @@ -836,7 +836,7 @@ void mutt_sort_threads (CONTEXT * ctx, int init) break; if ((new = hash_find (ctx->thread_hash, ref->data)) == NULL) { - new = safe_calloc (1, sizeof (THREAD)); + new = mem_calloc (1, sizeof (THREAD)); hash_insert (ctx->thread_hash, ref->data, new, 1); } else { diff --git a/url.c b/url.c index 84c17a6..2315fc9 100644 --- a/url.c +++ b/url.c @@ -253,6 +253,6 @@ int url_parse_mailto (ENVELOPE * e, char **body, const char *src) } } - FREE (&tmp); + mem_free (&tmp); return 0; } -- 2.20.1