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++) {
}
mutt_menuDestroy (&menu);
- FREE (&AliasTable);
+ mem_free (&AliasTable);
}
}
if (!i) {
- u = safe_malloc (sizeof (LIST));
+ u = mem_malloc (sizeof (LIST));
u->data = str_dup (a->mailbox);
u->next = *expn;
*expn = u;
}
}
- new = safe_calloc (1, sizeof (ALIAS));
+ new = mem_calloc (1, sizeof (ALIAS));
new->self = new;
new->name = str_dup (buf);
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));
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 */
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;
}
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);
}
}
}
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;
}
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)
{
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);
(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));
}
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;
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];
}
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;
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,
}
else
mutt_message _("Mailbox not deleted.");
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
}
break;
#endif
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;
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;
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);
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;
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;
}
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);
nntp_clear_cacheindex (news);
if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
regfree (rx);
- FREE (&rx);
+ mem_free (&rx);
}
#ifdef USE_IMAP
else
/* 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) {
}
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);
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);
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;
if (fc->cd != (iconv_t) - 1)
iconv_close (fc->cd);
- FREE (_fc);
+ mem_free (_fc);
}
char *mutt_get_first_charset (const char *charset)
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);
*tlen = ob - buf;
- safe_realloc (&buf, ob - buf + 1);
+ mem_realloc (&buf, ob - buf + 1);
*t = buf;
iconv_close (cd);
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;
}
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;
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;
i++;
}
- p = (COLOR_LIST *) safe_malloc (sizeof (COLOR_LIST));
+ p = (COLOR_LIST *) mem_malloc (sizeof (COLOR_LIST));
p->next = ColorList;
ColorList = p;
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;
}
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];
}
if (mutt_addrlist_to_idna (adr, &err) < 0) {
mutt_error (_("Bad IDN: '%s'"), err);
- FREE (&err);
+ mem_free (&err);
rfc822_free_address (&adr);
return;
}
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()
/* clean up previous junk */
mutt_free_parameter (&b->parameter);
- FREE (&b->subtype);
+ mem_free (&b->subtype);
mutt_parse_content_type (buf, b);
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 */
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);
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);
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);
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 ();
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 {
/* 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,
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;
break;
if (idxlen + numfiles >= idxmax) {
- safe_realloc (&idx,
+ mem_realloc (&idx,
sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles));
menu->data = idx;
}
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)
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 ();
if (!ctx->msgcount) {
mx_close_mailbox (ctx, NULL);
- FREE (&ctx);
+ mem_free (&ctx);
mutt_error _("No messages in that folder.");
break;
}
if (idxlen + Context->tagged >= idxmax) {
- safe_realloc (&idx,
+ mem_realloc (&idx,
sizeof (ATTACHPTR *) * (idxmax +=
5 + Context->tagged));
menu->data = idx;
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]);
}
}
}
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;
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);
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;
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);
}
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);
/* 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);
}
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);
if (!ci->open) {
ctx->magic = 0;
- FREE (ctx->compressinfo);
+ mem_free (ctx->compressinfo);
return (-1);
}
if (!ci->close || access (ctx->path, W_OK) != 0)
if ((fp = fopen (ctx->realpath, "r")) == NULL) {
mutt_perror (ctx->realpath);
- FREE (&cmd);
+ mem_free (&cmd);
return (-1);
}
mutt_block_signals ();
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
- FREE (&cmd);
+ mem_free (&cmd);
return (-1);
}
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);
void restore_path (CONTEXT * ctx)
{
- FREE (&ctx->path);
+ mem_free (&ctx->path);
ctx->path = ctx->realpath;
}
return (mutt_open_read_compressed (ctx));
ctx->magic = 0;
- FREE (&ctx->compressinfo);
+ mem_free (&ctx->compressinfo);
return (-1);
}
remove_file (ctx);
restore_path (ctx);
- FREE (&ctx->compressinfo);
+ mem_free (&ctx->compressinfo);
}
}
if ((fp = fopen (ctx->realpath, "a")) == NULL) {
mutt_perror (ctx->realpath);
- FREE (&cmd);
+ mem_free (&cmd);
return (-1);
}
mutt_block_signals ();
store_size (ctx);
- FREE (&cmd);
+ mem_free (&cmd);
return (-1);
}
mutt_unblock_signals ();
fclose (fp);
- FREE (&cmd);
+ mem_free (&cmd);
store_size (ctx);
if ((fp = fopen (ctx->realpath, "a")) == NULL) {
mutt_perror (ctx->realpath);
- FREE (&cmd);
+ mem_free (&cmd);
return (-1);
}
mutt_block_signals ();
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
- FREE (&cmd);
+ mem_free (&cmd);
return (-1);
}
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);
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;
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) {
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;
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__ */
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;
/* 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);
/* 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;
}
/* 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);
buflen = linelen + 3;
- safe_realloc (h, buflen);
+ mem_realloc (h, buflen);
for (count = 0; a; a = a->next, count++) {
ADDRESS *tmp = a->next;
}
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__ */
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);
rfc822_free_address (&a);
- FREE (&s);
+ mem_free (&s);
return 1;
}
{
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);
}
{
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;
while (*keylist) {
crypt_key_t *k = (*keylist)->next;
- FREE (&k);
+ mem_free (&k);
*keylist = k;
}
}
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;
}
}
}
/* NULL terminate. */
- safe_realloc (&rset, sizeof (*rset) * (rset_n + 1));
+ mem_realloc (&rset, sizeof (*rset) * (rset_n + 1));
rset[rset_n++] = NULL;
if (context)
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;
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;
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. */
*p++ = '\n';
*p = 0;
state_attach_puts (buf, state);
- FREE (&buf);
+ mem_free (&buf);
}
/* Show the valididy of a key used for one signature. */
if (!fname)
return;
unlink (fname);
- FREE (&fname);
+ mem_free (&fname);
fc = fgetconv_open (fp, charset, Charset, M_ICONV_HOOK_FROM);
}
else {
unlink (tmpfname);
- FREE (&tmpfname);
+ mem_free (&tmpfname);
}
}
gpgme_release (ctx);
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;
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);
n++;
}
- p = safe_malloc (n + 1);
+ p = mem_malloc (n + 1);
array->value = (char *) p;
for (s = string; n; s++, n--) {
if (*s == '\\') {
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 == ' ')
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;
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;
}
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);
}
}
}
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) {
err = gpgme_new (&ctx);
if (err) {
mutt_error (_("gpgme_new failed: %s"), gpgme_strerror (err));
- FREE (&pattern);
+ mem_free (&pattern);
return NULL;
}
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);
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;
}
#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;
if (err) {
mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err));
gpgme_release (ctx);
- FREE (&pattern);
+ mem_free (&pattern);
return NULL;
}
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;
}
gpgme_release (ctx);
- FREE (&pattern);
+ mem_free (&pattern);
return db;
}
hints = mutt_add_list (hints, t);
}
- FREE (&scratch);
+ mem_free (&scratch);
return hints;
}
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;
}
mutt_menuDestroy (&menu);
- FREE (&key_table);
+ mem_free (&key_table);
set_option (OPTNEEDREDRAW);
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);
}
}
else if (r == -1) {
- FREE (&keylist);
+ mem_free (&keylist);
rfc822_free_address (&tmp);
rfc822_free_address (&addr);
return NULL;
app,
#endif
&forced_valid)) == NULL) {
- FREE (&keylist);
+ mem_free (&keylist);
rfc822_free_address (&tmp);
rfc822_free_address (&addr);
return NULL;
#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 ? "!" : "");
}
/* 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;
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;
}
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"),
* 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 ();
*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);
!= 0)
buf[0] = 0;
MAYBE_REDRAW (*redraw);
- FREE (&pc);
+ mem_free (&pc);
}
return 0;
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;
}
/* 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];
mutt_uncollapse_thread (Context, h);
}
}
- FREE (&save_new);
+ mem_free (&save_new);
mutt_set_virtual (Context);
}
}
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);
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) ||
/* 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) {
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
break;
}
- FREE (&Context);
+ mem_free (&Context);
}
mutt_sleep (0);
{
if (Context) {
mx_fastclose_mailbox (Context);
- FREE (&Context);
+ mem_free (&Context);
}
done = 1;
}
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;
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,
}
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;
pfx);
if (*bufmax == *buflen)
- safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
+ mem_realloc (&buf, sizeof (char *) * (*bufmax += 25));
buf[(*buflen)++] = str_dup ("\n");
}
else
buflen--;
strfcpy (tmp, buf[buflen], sizeof (tmp));
tmp[str_len (tmp) - 1] = 0;
- FREE (&buf[buflen]);
+ mem_free (&buf[buflen]);
buf[buflen] = NULL;
continue;
}
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);
}
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;
}
{
/* 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));
/* 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);
}
/*
}
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 ();
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
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;
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));
bye:
- FREE (&tempbuf);
+ mem_free (&tempbuf);
return rv;
}
if (!esp)
return;
- FREE (&(*esp)->wbuf);
- FREE (esp);
+ mem_free (&(*esp)->wbuf);
+ mem_free (esp);
}
/*
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) {
else if (ob - buf == n && (buf[n] = 0, str_len (buf) < n))
memcpy (uid, buf, n);
}
- FREE (&buf);
+ mem_free (&buf);
iconv_close (cd);
}
}
return NULL;
if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB))))
- k = safe_calloc (sizeof *k, 1);
+ k = mem_calloc (sizeof *k, 1);
break;
}
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;
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;
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;
}
/* 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') {
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) {
((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;
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));
}
/*
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)
}
if (curline) {
print_flowed_line (curline, s, quotelevel);
- FREE (&curline);
+ mem_free (&curline);
}
}
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));
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;
}
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;
}
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;
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)
*last = ptr->next;
if (destroy)
destroy (ptr->data);
- FREE (&ptr);
+ mem_free (&ptr);
ptr = *last;
} else {
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);
}
siz = 4096;
}
- return safe_malloc (siz);
+ return mem_malloc (siz);
}
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)
return;
}
- *c = safe_malloc (size);
+ *c = mem_malloc (size);
memcpy (*c, d + *off, size);
*off += size;
}
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);
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--;
return;
}
- *b = safe_malloc (sizeof (BUFFER));
+ *b = mem_malloc (sizeof (BUFFER));
restore_char (&(*b)->data, d, off);
restore_int (&offset, d, 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;
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);
if (!path || path[0] == '\0')
{
- FREE(&h->folder);
- FREE(&h);
+ mem_free(&h->folder);
+ mem_free(&h);
return NULL;
}
return h;
else
{
- FREE(&h->folder);
- FREE(&h);
+ mem_free(&h->folder);
+ mem_free(&h);
return NULL;
}
return;
vlclose(h->db);
- FREE(&h->folder);
- FREE(&h);
+ mem_free(&h->folder);
+ mem_free(&h);
}
void *
if (! crc32_matches(data, h->crc))
{
- FREE(&data);
+ mem_free(&data);
return NULL;
}
ret = vlput(h->db, path, ksize, data, dsize, VL_DOVER);
- FREE(&data);
+ mem_free(&data);
return ret;
}
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;
h->crc = generate_crc32 ();
if (!path || path[0] == '\0') {
- FREE (&h->folder);
- FREE (&h);
+ mem_free (&h->folder);
+ mem_free (&h);
return NULL;
}
return h;
}
else {
- FREE (&h->folder);
- FREE (&h);
+ mem_free (&h->folder);
+ mem_free (&h);
return NULL;
}
}
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,
data = gdbm_fetch (h->db, key);
if (!crc32_matches (data.dptr, h->crc)) {
- FREE(&data.dptr);
+ mem_free(&data.dptr);
return NULL;
}
ret = gdbm_store (h->db, key, data, GDBM_REPLACE);
- FREE (&data.dptr);
+ mem_free (&data.dptr);
return ret;
}
h->crc = generate_crc32 ();
if (!path || path[0] == '\0') {
- FREE (&h);
+ mem_free (&h);
return NULL;
}
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;
}
if (ret) {
mx_unlock_file (h->lockfile, h->fd, 0);
close (h->fd);
- FREE (&h);
+ mem_free (&h);
return NULL;
}
h->env->close (h->env, 0);
mx_unlock_file (h->lockfile, h->fd, 0);
close (h->fd);
- FREE (&h);
+ mem_free (&h);
return NULL;
}
}
h->env->close (h->env, 0);
mx_unlock_file (h->lockfile, h->fd, 0);
close (h->fd);
- FREE (&h);
+ mem_free (&h);
return NULL;
}
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,
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;
}
ret = h->db->put (h->db, NULL, &key, &data, 0);
- FREE (&data.data);
+ mem_free (&data.data);
return ret;
}
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;
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);
}
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);
}
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);
}
* 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;
}
}
* 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;
}
}
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),
{
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;
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 */
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;
}
}
}
- FREE (&token.data);
+ mem_free (&token.data);
current_hook_type = 0;
}
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;
}
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);
}
}
- FREE (&token.data);
+ mem_free (&token.data);
}
#endif
!ascii_strcasecmp (authenticator->method, method))
if ((r = authenticator->authenticate (idata, method)) !=
IMAP_AUTH_UNAVAIL) {
- FREE (&methods);
+ mem_free (&methods);
return r;
}
}
}
- FREE (&methods);
+ mem_free (&methods);
}
else {
/* Fall back to default: any authenticator */
/* sasl_client_st(art|ep) allocate pc with malloc, expect me to
* free it */
#ifndef USE_SASL2
- FREE (&pc);
+ mem_free (&pc);
#endif
}
}
}
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return 0;
fail:
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return -1;
}
mutt_sleep (0);
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return 0;
fail:
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return -1;
}
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;
}
do {
if (imap_parse_list_response (idata, &name, &noselect, &noinferiors,
&idata->delim) != 0) {
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return -1;
}
}
while ((ascii_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0));
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return 0;
}
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) *
* 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;
}
(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)
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;
}
* 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));
}
/* 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));
}
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);
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));
if (!(idata = imap_conn_find (&mx.account,
option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW :
0))) {
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return -1;
}
/* 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))
if (!(idata = imap_conn_find (&mx.account,
option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW
: 0))) {
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return -1;
}
}
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);
else
mutt_account_unsetpass (&idata->conn->account);
- FREE (&idata->capstr);
+ mem_free (&idata->capstr);
}
if (idata->state == IMAP_AUTHENTICATED)
imap_get_delim (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);
mutt_socket_close (idata->conn);
idata->state = IMAP_DISCONNECTED;
bail:
- FREE (&idata->capstr);
+ mem_free (&idata->capstr);
return -1;
}
/* 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;
}
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");
}
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;
}
* 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;
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))
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);
}
/*
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) {
}
}
- FREE (&hdrs);
+ mem_free (&hdrs);
return count;
}
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;
}
}
idata->reopen &= IMAP_REOPEN_ALLOW;
- FREE (&(idata->mailbox));
+ mem_free (&(idata->mailbox));
mutt_free_list (&idata->flags);
idata->ctx = NULL;
}
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);
}
}
}
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));
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;
}
/* 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);
}
imap_qualify_path (dest, dlen, &mx, completion);
mutt_pretty_mailbox (dest);
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return 0;
}
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;
rewind (fp);
- FREE (&uid_validity);
+ mem_free (&uid_validity);
}
while ((rc != IMAP_CMD_OK) && ((mfhrc == -1) ||
/* 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
return 0;
else {
unlink (cache->path);
- FREE (&cache->path);
+ mem_free (&cache->path);
}
}
mutt_mktemp (path);
cache->path = str_dup (path);
if (!(msg->fp = safe_fopen (path, "w+"))) {
- FREE (&cache->path);
+ mem_free (&cache->path);
return -1;
}
safe_fclose (&msg->fp);
if (cache->path) {
unlink (cache->path);
- FREE (&cache->path);
+ mem_free (&cache->path);
}
return -1;
goto fail;
}
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return 0;
fail:
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return -1;
}
}
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;
}
/* 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
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;
}
mutt_free_list (&(HEADER_DATA (h)->keywords));
HEADER_DATA (h)->keywords = newh.data->keywords;
- FREE (&newh.data);
+ mem_free (&newh.data);
return s;
}
}
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;
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 == '&') {
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;
}
* 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;
}
if (u8len) {
- FREE (&buf);
+ mem_free (&buf);
return 0;
}
*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;
}
if (!mutt_convert_string (&t, Charset, "UTF-8", 0))
utf8_to_utf7 (t, str_len (t), s, 0);
- FREE (&t);
+ mem_free (&t);
}
}
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;
}
}
url.path = mx.mbox;
rc = url_ciss_tostring (&url, path, len, U_DECODE_PASSWD);
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
return rc;
}
if (!(url.scheme == U_IMAP || url.scheme == U_IMAPS) ||
mutt_account_fromurl (&mx->account, &url) < 0) {
- FREE (&c);
+ mem_free (&c);
return -1;
}
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;
if (target.mbox[hlen] == *delim)
home_match = 1;
}
- FREE (&home.mbox);
+ mem_free (&home.mbox);
}
/* do the '=' substitution */
url_ciss_tostring (&url, path, 1024, 0);
}
- FREE (&target.mbox);
+ mem_free (&target.mbox);
}
/* -- library functions -- */
* 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. */
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);
}
/*
imap_quote_string (dest, dlen, buf);
- FREE (&buf);
+ mem_free (&buf);
}
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 */
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);
}
}
/* 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;
/* 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)
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;
* 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 == '"')
}
if (var && (env = getenv (var)))
mutt_buffer_addstr (dest, env);
- FREE (&var);
+ mem_free (&var);
}
else
mutt_buffer_addch (dest, ch);
}
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;
* the template, and leaving t pointed at the current item.
*/
t = last;
- FREE(t->template);
+ mem_free(t->template);
break;
}
if (!last->next)
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;
}
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;
}
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;
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;
}
/* 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. */
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 */
/* 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;
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 == '!') {
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);
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];
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) {
}
}
- 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);
mutt_error (_("Error in %s, line %d: %s"), rcfile, line, err->data);
if (--rc < -MAXERRS) {
if (conv)
- FREE (¤tline);
+ mem_free (¤tline);
break;
}
}
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);
r = 0;
finish:
if (expn.destroy)
- FREE (&expn.data);
+ mem_free (&expn.data);
return (r);
}
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;
}
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;
}
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
memset (&token, 0, sizeof (token));
parse_my_hdr (&token, &buf, 0, &err);
- FREE (&token.data);
+ mem_free (&token.data);
}
if ((p = getenv ("EMAIL")) != NULL)
}
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
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)
((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;
}
#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
{
(list) = newp; \
} \
} while (0)
-# define FREE_BLOCKS(list) \
+# define mem_free_BLOCKS(list) \
do { \
while (list != NULL) { \
struct block_list *old = list; \
{
/* 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
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
{
/* 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)
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
fail:
for (i = nargs - 1; i >= 0; i--)
- FREE_EXPRESSION (args[i]);
+ mem_free_EXPRESSION (args[i]);
return NULL;
}
# 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 <stdlib.h> /* 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 */
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
+ YYSTACK_mem_free (yyss1);
}
# endif
#endif /* no yyoverflow */
}
}
yyerror (yymsg);
- YYSTACK_FREE (yymsg);
+ YYSTACK_mem_free (yymsg);
}
else
yyerror ("syntax error; also virtual memory exhausted");
yyreturn:
#ifndef yyoverflow
if (yyss != yyssa)
- YYSTACK_FREE (yyss);
+ YYSTACK_mem_free (yyss);
#endif
return yyresult;
}
void
internal_function
-FREE_EXPRESSION (exp)
+mem_free_EXPRESSION (exp)
struct expression *exp;
{
if (exp == NULL)
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;
{
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);
}
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);
strfcpy (err->data, _("too few arguments"), err->dsize);
}
error:
- FREE (&buf.data);
+ mem_free (&buf.data);
return (NULL);
}
}
}
}
- FREE (&key);
+ mem_free (&key);
return (r);
}
}
}
- FREE (&seq);
+ mem_free (&seq);
}
else {
for (i = 0; i < nummenus; ++i) {
}
}
}
- FREE (&key);
+ mem_free (&key);
return (r);
}
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) {
/* 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);
}
}
}
#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) {
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;
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);
}
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);
}
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);
}
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);
}
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);
#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;
}
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) {
* 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 <sys/types.h>
-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 */
#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);
}
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) {
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);
}
void str_replace (char **p, const char *s)
{
- FREE (p);
+ mem_free (p);
*p = str_dup (s);
}
{
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 */
else
len = str_len (begin);
- p = safe_malloc (len + 1);
+ p = mem_malloc (len + 1);
memcpy (p, begin, len);
p[len] = 0;
return p;
mutt_endwin (NULL);
perror (tempfile);
fclose (fin);
- FREE (&tempfile);
+ mem_free (&tempfile);
exit (1);
}
if (fin)
}
}
- FREE (&bodytext);
+ mem_free (&bodytext);
if (attach) {
LIST *t = attach;
if (option (OPTXTERMSETTITLES))
mutt_xterm_set_title (NONULL (XtermLeave));
if (Context)
- FREE (&Context);
+ mem_free (&Context);
}
mutt_endwin (Errorbuf);
}
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++) {
/*
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 ();
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!");
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 */
/* 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);
msg_mod = 1;
}
}
- FREE (&old_hdrs);
+ mem_free (&old_hdrs);
}
ctx->quiet = 0;
}
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;
{
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;
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)
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;
{
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
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;
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)
}
}
- FREE (&buff);
+ mem_free (&buff);
safe_fclose (&fp);
}
}
if ((*fp = fdopen (fd, "w")) == NULL) {
- FREE (tgt);
+ mem_free (tgt);
close (fd);
unlink (path);
return (-1);
unlink (tmpfname);
}
- FREE (&tmpfname);
+ mem_free (&tmpfname);
}
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);
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)
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)
}
if (q == h->maildir_flags)
- FREE (&h->maildir_flags);
+ mem_free (&h->maildir_flags);
else if (q)
*q = '\0';
}
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
else
mutt_free_header (&p->h);
#if USE_HCACHE
- FREE (&data);
+ mem_free (&data);
#endif
}
#if USE_HCACHE
}
if ((msg->fp = fdopen (fd, "w")) == NULL) {
- FREE (&msg->path);
+ mem_free (&msg->path);
close (fd);
unlink (path);
return (-1);
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
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) {
safe_fclose (&fp);
if (safe_rename (tmp, buf) == -1)
unlink (tmp);
- FREE (&tmp);
+ mem_free (&tmp);
}
}
/* 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;
} 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 *);
irrev = 1;
}
- FREE (&t2);
- FREE (&tmp);
+ mem_free (&t2);
+ mem_free (&tmp);
if (irrev)
goto notrans;
return 0;
notrans:
- FREE (out);
+ mem_free (out);
*out = str_dup (in);
return 1;
}
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;
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;
*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;
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;
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;
}
/* 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");
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++;
* 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 */
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__ */
/* 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);
conn->sockdata = sasldata->sockdata;
#ifndef USE_SASL2
- FREE (&sasldata->buf);
+ mem_free (&sasldata->buf);
#endif
sasldata->bpos = 0;
sasldata->blen = 0;
rc = (sasldata->msasl_write) (conn, pbuf, plen);
#ifndef USE_SASL2
- FREE (&pbuf);
+ mem_free (&pbuf);
#endif
if (rc != plen)
goto fail;
/* head is special case, doesn't need prev updated */
if (iter == conn) {
Connections = iter->next;
- FREE (&iter);
+ mem_free (&iter);
return;
}
if (iter->next == conn) {
tmp = iter->next;
iter->next = tmp->next;
- FREE (&tmp);
+ mem_free (&tmp);
return;
}
iter = iter->next;
{
CONNECTION *conn;
- conn = (CONNECTION *) safe_calloc (1, sizeof (CONNECTION));
+ conn = (CONNECTION *) mem_calloc (1, sizeof (CONNECTION));
conn->fd = -1;
return conn;
rc = getaddrinfo (host_idna, port, &hints, &res);
# ifdef HAVE_LIBIDN
- FREE (&host_idna);
+ mem_free (&host_idna);
# endif
if (rc) {
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);
}
# ifdef HAVE_LIBIDN
- FREE (&host_idna);
+ mem_free (&host_idna);
# endif
mutt_message (_("Connecting to %s..."), conn->account.host);
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"));
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;
}
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 ());
#endif
SSL_free (data->ssl);
SSL_CTX_free (data->ctx);
- FREE (&conn->sockdata);
+ mem_free (&conn->sockdata);
}
return raw_socket_close (conn);
/* 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:"),
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);
fail:
gnutls_certificate_free_credentials (data->xcred);
gnutls_deinit (data->state);
- FREE (&conn->sockdata);
+ mem_free (&conn->sockdata);
return -1;
}
gnutls_certificate_free_credentials (data->xcred);
gnutls_deinit (data->state);
- FREE(&conn->sockdata);
+ mem_free(&conn->sockdata);
}
return raw_socket_close (conn);
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;
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;
}
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;
}
}
} while (ptr != NULL);
/* no match found */
- FREE (&b64_data_data);
+ mem_free (&b64_data_data);
return 0;
}
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;
}
/* 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:"),
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);
NONULL(mutt_strsysexit(WEXITSTATUS(status))));
mutt_sleep (2);
}
- FREE (&conn->sockdata);
+ mem_free (&conn->sockdata);
return 0;
}
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;
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) */
if (b->parts)
mutt_free_body (&b->parts);
- FREE (&b);
+ mem_free (&b);
}
*p = 0;
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;
}
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;
while (*list) {
p = *list;
*list = (*list)->next;
- FREE (&p->data);
- FREE (&p);
+ mem_free (&p->data);
+ mem_free (&p);
}
}
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" */
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 */
while (*p) {
t = *p;
*p = (*p)->next;
- FREE (&t->name);
+ mem_free (&t->name);
rfc822_free_address (&t->addr);
- FREE (&t);
+ mem_free (&t);
}
}
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;
}
}
}
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--) {
wlen++;
}
col += mutt_strwidth (bar2);
- FREE (&bar2);
+ mem_free (&bar2);
}
}
*wptr = 0;
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)
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;
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.
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);
p = *list;
*list = (*list)->next;
rx_free (&p->rx);
- FREE(&p->template);
- FREE(&p);
+ mem_free(&p->template);
+ mem_free(&p);
}
}
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;
}
int rc;
if (!ctx)
- ctx = safe_malloc (sizeof (CONTEXT));
+ ctx = mem_malloc (sizeof (CONTEXT));
memset (ctx, 0, sizeof (CONTEXT));
ctx->path = str_dup (path);
if (mx_open_mailbox_append (ctx, flags) != 0) {
mx_fastclose_mailbox (ctx);
if (!pctx)
- FREE (&ctx);
+ mem_free (&ctx);
return NULL;
}
return ctx;
if (ctx->magic <= 0) {
mx_fastclose_mailbox (ctx);
if (!pctx)
- FREE (&ctx);
+ mem_free (&ctx);
return (NULL);
}
else {
mx_fastclose_mailbox (ctx);
if (!pctx)
- FREE (&ctx);
+ mem_free (&ctx);
}
unset_option (OPTFORCEREFRESH);
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);
return (NULL);
}
- msg = safe_calloc (1, sizeof (MESSAGE));
+ msg = mem_calloc (1, sizeof (MESSAGE));
msg->magic = dest->magic;
msg->write = 1;
}
}
else
- FREE (&msg);
+ mem_free (&msg);
return msg;
}
{
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:
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;
case M_IMAP:
{
if (imap_fetch_message (msg, ctx, msgno) != 0)
- FREE (&msg);
+ mem_free (&msg);
break;
}
#endif /* USE_IMAP */
case M_POP:
{
if (pop_fetch_message (msg, ctx, msgno) != 0)
- FREE (&msg);
+ mem_free (&msg);
break;
}
#endif /* USE_POP */
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);
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);
}
}
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;
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))
/* 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;
if (!s || !d)
return;
- l = safe_calloc (1, sizeof (LIST));
+ l = mem_calloc (1, sizeof (LIST));
if (s->list)
s->tail->next = l;
else
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;
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 == ':')
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);
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;
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);
ret = mutt_account_fromurl (acct, &url);
}
- FREE (&c);
+ mem_free (&c);
return ret;
}
url.path = str_dup (line);
mutt_account_tourl (acct, &url);
url_ciss_tostring (&url, line, len, 0);
- FREE (&url.path);
+ mem_free (&url.path);
}
/*
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');
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)
}
/* 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);
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);
len += *buflen;
*buflen *= 2;
line = *buf;
- safe_realloc (buf, *buflen);
+ mem_realloc (buf, *buflen);
line = *buf + (*pline - line);
}
strcpy (line, data->group);
*buflen *= 2;
*pline = line;
line = *buf;
- safe_realloc (buf, *buflen);
+ mem_realloc (buf, *buflen);
line = *buf + (*pline - line);
}
if (x) {
}
if (!data->max) {
- data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
+ data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY));
data->max = 5;
}
!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;
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;
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;
news->size = st.st_size;
news->mtime = st.st_mtime;
}
- FREE (&buf);
+ mem_free (&buf);
return r;
}
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,
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;
!(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;
!(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;
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,
lenbuf = 0;
}
- safe_realloc (&inbuf, lenbuf + sizeof (buf));
+ mem_realloc (&inbuf, lenbuf + sizeof (buf));
}
- FREE (&inbuf);
+ mem_free (&inbuf);
funct (NULL, data);
}
while (!done);
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;
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:
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);
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) !=
#ifdef DEBUG
nntp_error ("nntp_fetch_headers()", buf);
#endif
- FREE (&fc.messages);
+ mem_free (&fc.messages);
return -1;
}
}
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 {
}
num = last - first + 1;
if (num <= 0) {
- FREE (&fc.messages);
+ mem_free (&fc.messages);
return 0;
}
#ifdef DEBUG
nntp_error ("nntp_fetch_headers()", buf);
#endif
- FREE (&fc.messages);
+ mem_free (&fc.messages);
return -1;
}
/* fetched OK */
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;
/* 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);
mutt_mktemp (path);
cache->path = str_dup (path);
if (!(msg->fp = safe_fopen (path, "w+"))) {
- FREE (&cache->path);
+ mem_free (&cache->path);
return -1;
}
if (ret) {
fclose (msg->fp);
unlink (path);
- FREE (&cache->path);
+ mem_free (&cache->path);
return -1;
}
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);
}
}
}
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)
/* 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;
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;
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)
return 0;
}
else {
- FREE (&serv->cache);
+ mem_free (&serv->cache);
return -1;
}
}
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;
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
}
if (tmp)
set_option (OPTNEWSCACHE);
- FREE (&cc.child);
+ mem_free (&cc.child);
return ret;
}
cleanup_quote (&((*QuoteList)->down));
ptr = (*QuoteList)->next;
if ((*QuoteList)->prefix)
- FREE (&(*QuoteList)->prefix);
- FREE (QuoteList);
+ mem_free (&(*QuoteList)->prefix);
+ mem_free (QuoteList);
*QuoteList = ptr;
}
/* 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;
}
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;
/* 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;
/* 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;
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);
/* 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;
}
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));
}
}
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;
}
(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 =
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;
}
lines = Resize->line;
redraw |= REDRAW_SIGWINCH;
- FREE (&Resize);
+ mem_free (&Resize);
}
#endif
lines++;
if (flags & M_PAGER_RETWINCH) {
- Resize = safe_malloc (sizeof (struct resize));
+ Resize = mem_malloc (sizeof (struct resize));
Resize->line = lines;
Resize->SearchCompiled = SearchCompiled;
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;
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;
}
}
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;
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) {
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);
if (*linelen < offset + STRING) {
/* grow the buffer */
*linelen += STRING;
- safe_realloc (&line, *linelen);
+ mem_realloc (&line, *linelen);
buf = line + offset;
}
}
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__ */
}
*/
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;
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;
char *pc;
char *subtype;
- FREE (&ct->subtype);
+ mem_free (&ct->subtype);
mutt_free_parameter (&ct->parameter);
/* First extract any existing parameters */
{
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);
else if (p->type == TYPEMESSAGE && !p->subtype)
p->subtype = str_dup ("rfc822");
- FREE (&line);
+ mem_free (&line);
return (p);
}
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);
/* 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;
}
}
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;
}
#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;
{
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;
}
- FREE (&line);
+ mem_free (&line);
if (hdr) {
hdr->content->hdr_offset = hdr->offset;
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;
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;
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);
}
}
pat->min = mutt_mktime (&min, 1);
pat->max = mutt_mktime (&max, 1);
- FREE (&buffer.data);
+ mem_free (&buffer.data);
return 0;
}
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);
}
}
/* 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
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);
}
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) {
Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err);
}
}
- FREE (&simple);
+ mem_free (&simple);
mutt_pattern_free (&pat);
return 0;
}
fputs (line, fpout);
fputc ('\n', fpout);
}
- FREE (&line);
+ mem_free (&line);
}
else {
debug_print (2, ("No pattern.\n"));
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;
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;
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);
if (i == keymax) {
keymax += 5;
- safe_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax);
+ mem_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax);
}
KeyTable[i++] = a;
}
mutt_menuDestroy (&menu);
- FREE (&KeyTable);
+ mem_free (&KeyTable);
set_option (OPTNEEDREDRAW);
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);
hints = mutt_add_list (hints, t);
}
- FREE (&scratch);
+ mem_free (&scratch);
return hints;
}
for (sp = *sigp; sp; sp = q) {
q = sp->next;
- FREE (&sp);
+ mem_free (&sp);
}
*sigp = NULL;
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;
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);
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)
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 */
if (!plen) {
plen = CHUNKSIZE;
- pbuf = safe_malloc (plen);
+ pbuf = mem_malloc (plen);
}
if (fread (&ctb, 1, 1, fp) < 1) {
void pgp_release_packet (void)
{
plen = 0;
- FREE (&pbuf);
+ mem_free (&pbuf);
}
bailout:
- FREE (&p);
+ mem_free (&p);
return NULL;
}
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;
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;
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;
}
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';
pgp_free_key (&p);
}
- FREE (&tmp);
+ mem_free (&tmp);
}
FGETPOS (rfp, pos);
}
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;
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;
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);
}
}
}
else {
/* clear the previous entry */
unlink (cache->path);
- FREE (&cache->path);
+ mem_free (&cache->path);
}
}
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');
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;
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;
}
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);
}
/* sasl_client_st(art|ep) allocate pc with malloc, expect me to
* free it */
#ifndef USE_SASL2
- FREE (&pc);
+ mem_free (&pc);
#endif
}
}
{
char *p1, *p2;
- FREE (&pop_data->timestamp);
+ mem_free (&pop_data->timestamp);
if ((p1 = strchr (buf, '<')) && (p2 = strchr (p1, '>'))) {
p2[1] = '\0';
method = comma;
}
- FREE (&methods);
+ mem_free (&methods);
}
else {
/* Fall back to default: any authenticator */
ret = 0;
}
- FREE (&c);
+ mem_free (&c);
return ret;
}
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);
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__ */
}
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 */
if (ret != PQ_OK)
return ret;
- inbuf = safe_malloc (sizeof (buf));
+ inbuf = mem_malloc (sizeof (buf));
FOREVER {
chunk =
lenbuf = 0;
}
- safe_realloc (&inbuf, lenbuf + sizeof (buf));
+ mem_realloc (&inbuf, lenbuf + sizeof (buf));
}
- FREE (&inbuf);
+ mem_free (&inbuf);
return ret;
}
if (!PostContext->msgcount) {
PostCount = 0;
mx_close_mailbox (PostContext, NULL);
- FREE (&PostContext);
+ mem_free (&PostContext);
mutt_error _("No postponed messages.");
return (-1);
}
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);
}
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) {
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 */
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 *,
(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);
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;
}
}
}
}
- FREE (&buf);
+ mem_free (&buf);
fclose (fp);
if (mutt_wait_filter (thepid)) {
debug_print (1, ("Error: %s\n", msg));
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;
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 */
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++)
int clear = 0;
/* append */
- safe_realloc (&QueryTable, menu->max * sizeof (ENTRY));
+ mem_realloc (&QueryTable, menu->max * sizeof (ENTRY));
menu->data = QueryTable;
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);
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;
}
*help_ptr++ = *filename++;
}
- FREE (&tmp);
+ mem_free (&tmp);
return 0;
}
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;
}
}
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;
break;
}
- FREE (&directory);
+ mem_free (&directory);
if (tag && menu) {
menu->oldcurrent = menu->current;
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) {
if (mutt_addrlist_to_idna (adr, &err) < 0) {
mutt_error (_("Bad IDN: '%s'"), err);
- FREE (&err);
+ mem_free (&err);
rfc822_free_address (&adr);
return;
}
#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 */
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 */
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 */
#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 */
#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 */
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 { \
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
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;
}
/* 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;
}
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 == '?')) {
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. */
/* 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);
/* 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
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. */
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
/* If pattern is `[[:'. */
if (p == pend)
- FREE_STACK_RETURN (REG_EBRACK);
+ mem_free_STACK_RETURN (REG_EBRACK);
for (;;) {
PATFETCH (c);
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))
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
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
if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) {
goto normal_backslash;
} else {
- FREE_STACK_RETURN (REG_ERPAREN);
+ mem_free_STACK_RETURN (REG_ERPAREN);
}
}
if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) {
goto normal_char;
} else {
- FREE_STACK_RETURN (REG_ERPAREN);
+ mem_free_STACK_RETURN (REG_ERPAREN);
}
}
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);
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);
}
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. */
/* 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
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))
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. */
/* 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
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;
/* The starting position is bogus. */
if (pos < 0 || pos > size1 + size2) {
- FREE_VARIABLES ();
+ mem_free_VARIABLES ();
return -1;
}
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;
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;
}
}
DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
- FREE_VARIABLES ();
+ mem_free_VARIABLES ();
return mcnt;
}
if (best_regs_set)
goto restore_best_regs;
- FREE_VARIABLES ();
+ mem_free_VARIABLES ();
return -1; /* Failure to match. */
} /* re_match_2 */
{
if (*used == *slots) {
*slots += 5;
- safe_realloc (type2_list, sizeof (REMAILER *) * (*slots));
+ mem_realloc (type2_list, sizeof (REMAILER *) * (*slots));
}
(*type2_list)[(*used)++] = 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 */
for (i = 0; type2_list[i]; i++)
mix_free_remailer (&type2_list[i]);
- FREE (type2_list);
+ mem_free (type2_list);
}
if (!chain->cl)
return;
- safe_realloc (coordsp, sizeof (struct coord) * chain->cl);
+ mem_realloc (coordsp, sizeof (struct coord) * chain->cl);
coords = *coordsp;
*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);
}
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 */
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) */
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;
}
} /* 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);
}
/*
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);
*tlen = ob - buf;
- safe_realloc (&buf, ob - buf + 1);
+ mem_realloc (&buf, ob - buf + 1);
*t = buf;
iconv_close (cd);
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';
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) {
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;
}
/* 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);
#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);
/* 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';
Charset, charsets, &e, &elen,
encode_specials ? RFC822Specials : NULL);
- FREE (pd);
+ mem_free (pd);
*pd = e;
}
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++;
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;
else if (toupper ((unsigned char) *pp) == 'B')
enc = ENCBASE64;
else {
- FREE (&charset);
- FREE (&d0);
+ mem_free (&charset);
+ mem_free (&d0);
return (-1);
}
break;
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);
}
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))) {
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);
strncpy (d, s, n);
d += n;
}
- FREE (&t);
+ mem_free (&t);
break;
}
}
}
*d = 0;
- FREE (pd);
+ mem_free (pd);
*pd = d0;
str_adjust (pd);
}
p->attribute = NULL;
p->value = NULL;
- FREE (&p);
+ mem_free (&p);
rfc2231_list_insert (&conthead, conttmp);
}
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);
}
}
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;
++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--)
*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;
}
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);
}
}
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);
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;
}
}
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);
}
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
last = tmp;
tmp = tmp->next;
mutt_pattern_free (&last->pat);
- FREE (&last);
+ mem_free (&last);
}
Score = NULL;
}
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;
}
mutt_error (_("Error: '%s' is a bad IDN."), err);
mutt_refresh ();
mutt_sleep (2);
- FREE (&err);
+ mem_free (&err);
}
}
while (idna_ok != 0);
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)
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)
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
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) {
* 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)
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);
}
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 {
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
mutt_protect (msg, pgpkeylist) == -1) {
msg->content = mutt_remove_multipart (msg->content);
- FREE (&pgpkeylist);
+ mem_free (&pgpkeylist);
decode_descriptions (msg->content);
goto main_loop;
#endif
if (WithCrypto && (msg->security & ENCRYPT))
- FREE (&pgpkeylist);
+ mem_free (&pgpkeylist);
if (WithCrypto && free_clear_content)
mutt_free_body (&clear_content);
if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED)) {
if (signas) {
- FREE (&PgpSignAs);
+ mem_free (&PgpSignAs);
PgpSignAs = signas;
}
}
&& !strcmp (buffer, tmp))
snprintf (buffer, sizeof (buffer), "\"%s\"", tmp);
- FREE (&tmp);
+ mem_free (&tmp);
tmplen = str_len (buffer) + str_len (p->attribute) + 1;
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);
}
}
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"))
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
}
/* 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;
tcode[cn] = 0;
break;
}
- FREE (&fcode);
+ mem_free (&fcode);
}
}
else {
/* Free memory */
for (i = 0; i < ncodes; i++)
- FREE (&tcode[i]);
+ mem_free (&tcode[i]);
- FREE (tcode);
+ mem_free (tcode);
return ret;
}
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)) {
mutt_set_parameter ("charset", chsbuf, &b->parameter);
}
b->file_charset = fromcode;
- FREE (&tocode);
+ mem_free (&tocode);
safe_fclose (&fp);
return info;
}
mutt_write_mime_body (a->parts, fpout);
cleanup:
- FREE (&line);
+ mem_free (&line);
if (fpin && !fp)
fclose (fpin);
mutt_set_encoding (a, info);
mutt_stamp_attachment (a);
- FREE (&a->content);
+ mem_free (&a->content);
a->content = info;
}
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;
}
fputs (ref[refcnt]->data, f);
}
- FREE (&ref);
+ mem_free (&ref);
}
/* Note: all RFC2047 encoding should be done outside of this routine, except
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);
}
}
}
else if (pid == -1) {
unlink (msg);
- FREE (tempfile);
+ mem_free (tempfile);
_exit (S_ERR);
}
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);
}
}
if (kill (ppid, 0) == -1 && errno == ESRCH) {
/* the parent is already dead */
unlink (*tempfile);
- FREE (tempfile);
+ mem_free (tempfile);
}
_exit (st);
/* 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;
}
}
char *s)
{
if (*argslen == *argsmax)
- safe_realloc (&args, (*argsmax += 5) * sizeof (char *));
+ mem_realloc (&args, (*argsmax += 5) * sizeof (char *));
args[(*argslen)++] = s;
return (args);
}
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;
#endif
if (argslen == argsmax)
- safe_realloc (&args, sizeof (char *) * (++argsmax));
+ mem_realloc (&args, sizeof (char *) * (++argsmax));
args[argslen++] = NULL;
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;
{
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);
}
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++ = '\\';
}
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])) {
addnstr (entry, len);
if (shortened)
- FREE(&box);
+ mem_free(&box);
return (1);
}
}
/* 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),
}
}
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)
/* the key used last time. */
if (*SmimeKeyToUse &&
!str_casecmp (k, SmimeKeyToUse + str_len (SmimeKeys) + 1)) {
- FREE (&k);
+ mem_free (&k);
return;
}
else
if (str_casecmp (k, SmimeDefaultKey))
smime_void_passphrase ();
- FREE (&k);
+ mem_free (&k);
return;
}
}
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);
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++;
}
mutt_wait_filter (thepid);
mutt_unlink (certfile);
- FREE (&certfile);
+ mem_free (&certfile);
}
fflush (fpout);
else
retval = 0;
mutt_unlink (certfile);
- FREE (&certfile);
+ mem_free (&certfile);
}
else
mutt_any_key_to_continue (_("no certfile"));
if (linelen && !str_casecmp (line, "verification successful"))
badsig = 0;
- FREE (&line);
+ mem_free (&line);
}
}
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;
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;
* 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;
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,
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
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;
oldlist = subjects;
subjects = subjects->next;
- FREE (&oldlist);
+ mem_free (&oldlist);
}
return (last);
}
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;
/* 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;
}
}
else {
Sort ^= SORT_REVERSE;
- FREE (&array);
+ mem_free (&array);
return (top);
}
}
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;
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 {
}
}
- FREE (&tmp);
+ mem_free (&tmp);
return 0;
}