#include <config.h>
#endif
+#include <lib-lib/mem.h>
+
#include "mutt.h"
#include "mutt_curses.h"
#include "sort.h"
if (!s || !d)
return;
- l = mem_calloc (1, sizeof (LIST));
+ l = p_new(LIST, 1);
if (s->list)
s->tail->next = l;
else
len = sizeof (group);
strfcpy (group, line, len);
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) {
- data =
- (NNTP_DATA *) mem_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1);
+ data = xmalloc(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
- mem_free ((void **) &data->entries);
+ p_delete(&data->entries);
data->rc = 1;
- data->entries = mem_calloc (x * 2, sizeof (NEWSRC_ENTRY));
+ data->entries = p_new(NEWSRC_ENTRY, x * 2);
data->max = x * 2;
if (*p == ':')
return -1;
}
- buf = mem_malloc (sb.st_size + 1);
+ buf = p_new(char, sb.st_size + 1);
while (fgets (buf, sb.st_size + 1, fp))
nntp_parse_newsrc_line (news, buf);
- mem_free (&buf);
+ p_delete(&buf);
mx_unlock_file (news->newsrc, fileno (fp), 0);
fclose (fp);
set_option (OPTNEWSCACHE);
- mem_free (&news->cache);
+ p_delete(&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 *) mem_calloc (1,
- sizeof (NNTP_DATA) + str_len (buf) + 1);
+ data = xmalloc(sizeof(NNTP_DATA) + str_len(buf) + 1);
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, buf);
data->nserv = news;
ret = mutt_account_fromurl (acct, &url);
}
- mem_free (&c);
+ p_delete(&c);
return ret;
}
url.path = str_dup (line);
mutt_account_tourl (acct, &url);
url_ciss_tostring (&url, line, len, 0);
- mem_free (&url.path);
+ p_delete(&url.path);
}
/*
return NULL;
}
- buf = p = mem_calloc (str_len (server) + 10, sizeof (char));
+ buf = p = p_new(char, str_len (server) + 10);
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) {
- mem_free (&buf);
+ p_delete(&buf);
mutt_error (_("%s is an invalid newsserver specification!"), server);
return NULL;
}
- mem_free (&buf);
+ p_delete(&buf);
conn = mutt_conn_find (NULL, &acct);
if (!conn)
}
/* New newsserver */
- serv = mem_calloc (1, sizeof (NNTP_SERVER));
+ serv = p_new(NNTP_SERVER, 1);
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);
- mem_free (&serv->newsrc);
- mem_free (&serv->cache);
- mem_free (&serv);
+ p_delete(&serv->newsrc);
+ p_delete(&serv->cache);
+ p_delete(&serv);
return NULL;
}
nntp_clear_cacheindex (serv);
}
if (!data->max) {
- data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY));
+ data->entries = p_new(NEWSRC_ENTRY, 5);
data->max = 5;
}
if (!news)
return -1;
llen = len = 10 * LONG_STRING;
- line = buf = mem_calloc (1, len);
+ line = buf = p_new(char, 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;
}
- mem_free (&buf);
+ p_delete(&buf);
return r;
}
fputs (buf, f);
if (h->env->references)
mutt_write_references (h->env->references, f);
- snprintf (buf, sizeof (buf), "\t" OFF_T_FMT "\t%d\tXref: %s\n",
+ snprintf (buf, sizeof (buf), "\t%zd\t%d\tXref: %s\n",
h->content->length, h->lines, NONULL (h->env->xref));
if (fputs (buf, f) == EOF) {
fclose (f);
nntp_cache_expand (buf, data->cache);
unlink (buf);
- mem_free (&data->cache);
+ p_delete(&data->cache);
data->lastCached = 0;
nntp_cache_expand (buf, ".index");
mutt_update_list_file (buf, data->nserv->conn->account.host, data->group,
if (!news || !news->newsgroups || !group || !*group)
return NULL;
if (!(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) {
- data =
- (NNTP_DATA *) mem_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1);
+ data = xmalloc(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 = mem_calloc (5, sizeof (NEWSRC_ENTRY));
+ data->entries = p_new(NEWSRC_ENTRY, 5);
data->max = 5;
}
data->num = 1;
!(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
return NULL;
if (!data->max) {
- data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY));
+ data->entries = p_new(NEWSRC_ENTRY, 5);
data->max = 5;
}
data->num = 1;