X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=nntp%2Fnewsrc.c;h=b711b2f595f94fbf8877b41aa4a85c37a92c1b54;hb=23002a877577341cfd68687e58348e0ca01b1ac5;hp=8e57a10884c010d37d915581cc7b6d35a7c2a77b;hpb=ea912b20ba2b3b9dfdbbae758ad56263c9aa41b3;p=apps%2Fmadmutt.git diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 8e57a10..b711b2f 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -13,6 +13,8 @@ #include #endif +#include + #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; - l = mem_calloc (1, sizeof (LIST)); + l = p_new(LIST, 1); 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) { - 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; @@ -87,10 +88,10 @@ static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line) nntp_add_to_list (news, data); } else - mem_free (&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 == ':') @@ -149,10 +150,10 @@ static int slurp_newsrc (NNTP_SERVER * news) 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); @@ -200,7 +201,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) 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; @@ -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) { - 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; @@ -305,7 +304,7 @@ int nntp_parse_url (const char *server, ACCOUNT * acct, ret = mutt_account_fromurl (acct, &url); } - mem_free (&c); + p_delete(&c); 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); - mem_free (&url.path); + p_delete(&url.path); } /* @@ -346,7 +345,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server) 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'); @@ -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) { - 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) @@ -396,7 +395,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server) } /* 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); @@ -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); - 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); @@ -575,7 +574,7 @@ void newsrc_gen_entries (CONTEXT * ctx) } if (!data->max) { - data->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY)); + data->entries = p_new(NEWSRC_ENTRY, 5); data->max = 5; } @@ -754,7 +753,7 @@ int mutt_newsrc_update (NNTP_SERVER * news) 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; @@ -773,7 +772,7 @@ int mutt_newsrc_update (NNTP_SERVER * news) news->size = st.st_size; news->mtime = st.st_mtime; } - mem_free (&buf); + p_delete(&buf); 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); - 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); @@ -980,7 +979,7 @@ void nntp_delete_cache (NNTP_DATA * data) 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, @@ -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))) { - 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; @@ -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->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY)); + data->entries = p_new(NEWSRC_ENTRY, 5); 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->entries = mem_calloc (5, sizeof (NEWSRC_ENTRY)); + data->entries = p_new(NEWSRC_ENTRY, 5); data->max = 5; } data->num = 1;