From 1f34780e2ee55984ebd4265bd7b308c6aeee348f Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 26 May 2007 19:41:08 +0200 Subject: [PATCH] tail is always a list_item**. Because you don't need to special case the empty list *gee*. Fix code using tail. Signed-off-by: Pierre Habouzit --- nntp/newsrc.c | 18 +++++------------- nntp/nntp.c | 26 ++++++++++---------------- nntp/nntp.h | 2 +- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 59ca74f..c919d86 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -21,20 +21,11 @@ #include "sort.h" #include "nntp.h" -void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d) +void nntp_add_to_list(NNTP_SERVER *s, NNTP_DATA *d) { - string_list_t *l; - - if (!s || !d) - return; - - l = p_new(string_list_t, 1); - if (s->list) - s->tail->next = l; - else - s->list = l; - s->tail = l; - l->data = (void *) d; + *s->tail = p_new(string_list_t, 1); + (*s->tail)->data = (void *)d; + s->tail = &(*s->tail)->next; } static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line) @@ -376,6 +367,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server) /* New newsserver */ serv = p_new(NNTP_SERVER, 1); + serv->tail = &serv->list; serv->conn = conn; serv->newsrc = m_strdup(file); serv->newsgroups = hash_new(1009, false); diff --git a/nntp/nntp.c b/nntp/nntp.c index 7409044..b39e67a 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -1240,8 +1240,7 @@ int nntp_check_newgroups (NNTP_SERVER * serv, int force) { char buf[LONG_STRING]; NNTP_DATA nntp_data; - string_list_t *l; - string_list_t emp; + string_list_t *l, **emp; time_t now; struct tm *t; @@ -1278,7 +1277,8 @@ int nntp_check_newgroups (NNTP_SERVER * serv, int force) nntp_data.group = ((NNTP_DATA *) Context->data)->group; else nntp_data.group = NULL; - l = serv->tail; + + emp = serv->tail; if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."), NULL, add_group, serv, 0) != 0) { return -1; @@ -1286,20 +1286,14 @@ int nntp_check_newgroups (NNTP_SERVER * serv, int force) mutt_message _("Loading descriptions..."); - if (l) - emp.next = l->next; - else - emp.next = serv->list; - l = &emp; - while (l->next) { - l = l->next; - ((NNTP_DATA *) l->data)->new = 1; - nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, - NULL, NULL); + for (l = *emp; l; l = l->next) { + ((NNTP_DATA *)l->data)->new = 1; + nntp_get_desc((NNTP_DATA *) l->data, ((NNTP_DATA *)l->data)->group, + NULL, NULL); } - if (emp.next) - nntp_save_cache_index (serv); - mutt_clear_error (); + if (*emp) + nntp_save_cache_index(serv); + mutt_clear_error(); return _checked; } diff --git a/nntp/nntp.h b/nntp/nntp.h index 0fe2605..18b20fe 100644 --- a/nntp/nntp.h +++ b/nntp/nntp.h @@ -50,7 +50,7 @@ typedef struct { time_t check_time; hash_t *newsgroups; string_list_t *list; /* list of newsgroups */ - string_list_t *tail; /* last entry of list */ + string_list_t **tail; /* last entry of list */ CONNECTION *conn; } NNTP_SERVER; -- 2.20.1