projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix segfault
[apps/madmutt.git]
/
nntp
/
newsrc.c
diff --git
a/nntp/newsrc.c
b/nntp/newsrc.c
index
8e57a10
..
b711b2f
100644
(file)
--- a/
nntp/newsrc.c
+++ b/
nntp/newsrc.c
@@
-13,6
+13,8
@@
#include <config.h>
#endif
#include <config.h>
#endif
+#include <lib-lib/mem.h>
+
#include "mutt.h"
#include "mutt_curses.h"
#include "sort.h"
#include "mutt.h"
#include "mutt_curses.h"
#include "sort.h"
@@
-42,7
+44,7
@@
void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d)
if (!s || !d)
return;
if (!s || !d)
return;
- l =
mem_calloc (1, sizeof (LIST)
);
+ l =
p_new(LIST, 1
);
if (s->list)
s->tail->next = l;
else
if (s->list)
s->tail->next = l;
else
@@
-74,8
+76,7
@@
static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
len = sizeof (group);
strfcpy (group, line, len);
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) {
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;
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, group);
data->nserv = news;
@@
-87,10
+88,10
@@
static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
nntp_add_to_list (news, data);
}
else
nntp_add_to_list (news, data);
}
else
-
mem_free
(&data->entries);
+
p_delete
(&data->entries);
data->rc = 1;
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 == ':')
data->max = x * 2;
if (*p == ':')
@@
-149,10
+150,10
@@
static int slurp_newsrc (NNTP_SERVER * news)
return -1;
}
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);
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);
mx_unlock_file (news->newsrc, fileno (fp), 0);
fclose (fp);
@@
-200,7
+201,7
@@
static int nntp_parse_cacheindex (NNTP_SERVER * news)
set_option (OPTNEWSCACHE);
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;
snprintf (buf, sizeof (buf), "%s/.index", dir);
if (!(index = safe_fopen (buf, "a+")))
return 0;
@@
-227,9
+228,7
@@
static int nntp_parse_cacheindex (NNTP_SERVER * news)
}
else if (news->newsgroups) {
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, buf)) == NULL) {
}
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;
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, buf);
data->nserv = news;
@@
-305,7
+304,7
@@
int nntp_parse_url (const char *server, ACCOUNT * acct,
ret = mutt_account_fromurl (acct, &url);
}
ret = mutt_account_fromurl (acct, &url);
}
-
mem_free
(&c);
+
p_delete
(&c);
return ret;
}
return ret;
}
@@
-316,7
+315,7
@@
void nntp_expand_path (char *line, size_t len, ACCOUNT * acct)
url.path = str_dup (line);
mutt_account_tourl (acct, &url);
url_ciss_tostring (&url, line, len, 0);
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);
}
/*
}
/*
@@
-346,7
+345,7
@@
NNTP_SERVER *mutt_select_newsserver (char *server)
return NULL;
}
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');
if (url_check_scheme (server) == U_UNKNOWN) {
strcpy (buf, "nntp://");
p = strchr (buf, '\0');
@@
-354,11
+353,11
@@
NNTP_SERVER *mutt_select_newsserver (char *server)
strcpy (p, server);
if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file) {
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;
}
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)
conn = mutt_conn_find (NULL, &acct);
if (!conn)
@@
-396,7
+395,7
@@
NNTP_SERVER *mutt_select_newsserver (char *server)
}
/* New newsserver */
}
/* 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);
serv->conn = conn;
serv->newsrc = str_dup (file);
serv->newsgroups = hash_create (1009);
@@
-409,9
+408,9
@@
NNTP_SERVER *mutt_select_newsserver (char *server)
for (list = serv->list; list; list = list->next)
list->data = NULL;
mutt_free_list (&serv->list);
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);
return NULL;
}
nntp_clear_cacheindex (serv);
@@
-575,7
+574,7
@@
void newsrc_gen_entries (CONTEXT * ctx)
}
if (!data->max) {
}
if (!data->max) {
- data->entries =
mem_calloc (5, sizeof (NEWSRC_ENTRY)
);
+ data->entries =
p_new(NEWSRC_ENTRY, 5
);
data->max = 5;
}
data->max = 5;
}
@@
-754,7
+753,7
@@
int mutt_newsrc_update (NNTP_SERVER * news)
if (!news)
return -1;
llen = len = 10 * LONG_STRING;
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;
/* we will generate full newsrc here */
for (tmp = news->list; tmp; tmp = tmp->next) {
data = (NNTP_DATA *) tmp->data;
@@
-773,7
+772,7
@@
int mutt_newsrc_update (NNTP_SERVER * news)
news->size = st.st_size;
news->mtime = st.st_mtime;
}
news->size = st.st_size;
news->mtime = st.st_mtime;
}
-
mem_free
(&buf);
+
p_delete
(&buf);
return r;
}
return r;
}
@@
-944,7
+943,7
@@
int nntp_save_cache_group (CONTEXT * ctx)
fputs (buf, f);
if (h->env->references)
mutt_write_references (h->env->references, f);
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);
h->content->length, h->lines, NONULL (h->env->xref));
if (fputs (buf, f) == EOF) {
fclose (f);
@@
-980,7
+979,7
@@
void nntp_delete_cache (NNTP_DATA * data)
nntp_cache_expand (buf, data->cache);
unlink (buf);
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,
data->lastCached = 0;
nntp_cache_expand (buf, ".index");
mutt_update_list_file (buf, data->nserv->conn->account.host, data->group,
@@
-994,8
+993,7
@@
NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER * news, char *group)
if (!news || !news->newsgroups || !group || !*group)
return NULL;
if (!(data = (NNTP_DATA *) hash_find (news->newsgroups, 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->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, group);
data->nserv = news;
@@
-1036,7
+1034,7
@@
NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER * news, char *group)
!(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
return NULL;
if (!data->max) {
!(data = (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->max = 5;
}
data->num = 1;
@@
-1060,7
+1058,7
@@
NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER * news, char *group)
!(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
return NULL;
if (!data->max) {
!(data = (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->max = 5;
}
data->num = 1;