From: Pierre Habouzit Date: Wed, 15 Nov 2006 12:05:33 +0000 (+0100) Subject: use more ad-hoc list handling function, and avoid to muck with ->next X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=01bd0a7410e476abaebf03d820bcf31a5ec4c7c0 use more ad-hoc list handling function, and avoid to muck with ->next pointer ourselves Signed-off-by: Pierre Habouzit --- diff --git a/commands.c b/commands.c index 2054d12..bc05999 100644 --- a/commands.c +++ b/commands.c @@ -826,7 +826,6 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp) char buf[LONG_STRING]; char obuf[LONG_STRING]; char tmp[STRING]; - PARAMETER *p; char charset[STRING]; char *cp; @@ -840,6 +839,7 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp) snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype); m_strcpy(obuf, sizeof(obuf), buf); if (b->parameter) { + PARAMETER *p; ssize_t l; for (p = b->parameter; p; p = p->next) { diff --git a/hcache.c b/hcache.c index 8560ef6..da3d6bb 100644 --- a/hcache.c +++ b/hcache.c @@ -236,14 +236,12 @@ restore_parameter (PARAMETER ** p, const unsigned char *d, int *off) restore_int (&counter, d, off); while (counter) { - *p = p_new(PARAMETER, 1); + *p = parameter_new(); restore_char (&(*p)->attribute, d, off); restore_char (&(*p)->value, d, off); p = &(*p)->next; counter--; } - - *p = NULL; } static unsigned char *dump_body (BODY * c, unsigned char *d, int *off) diff --git a/lib-mime/rfc2231.c b/lib-mime/rfc2231.c index bf05bef..b5a2553 100644 --- a/lib-mime/rfc2231.c +++ b/lib-mime/rfc2231.c @@ -140,9 +140,8 @@ static void purge_empty_parameters(PARAMETER **headp) PARAMETER *p = *headp; if (!p->attribute || !p->value) { - *headp = p->next; - p->next = NULL; - parameter_list_wipe(&p); + p = parameter_list_pop(headp); + parameter_delete(&p); } else { headp = &(*headp)->next; } diff --git a/muttlib.c b/muttlib.c index fbd4564..d607b4f 100644 --- a/muttlib.c +++ b/muttlib.c @@ -402,35 +402,36 @@ char *_mutt_expand_path (char *s, ssize_t slen, int rx) char *mutt_get_parameter (const char *s, PARAMETER * p) { - for (; p; p = p->next) - if (ascii_strcasecmp (s, p->attribute) == 0) - return (p->value); + while (p) { + if (!ascii_strcasecmp(s, p->attribute)) + return (p->value); + p = p->next; + } - return NULL; + return NULL; } void mutt_set_parameter (const char *attribute, const char *value, PARAMETER ** p) { - PARAMETER *q; + PARAMETER *q; - if (!value) { - mutt_delete_parameter (attribute, p); - return; - } + if (!value) { + mutt_delete_parameter (attribute, p); + return; + } - for (q = *p; q; q = q->next) { - if (ascii_strcasecmp (attribute, q->attribute) == 0) { - m_strreplace(&q->value, value); - return; + for (q = *p; q; q = q->next) { + if (ascii_strcasecmp (attribute, q->attribute) == 0) { + m_strreplace(&q->value, value); + return; + } } - } - q = parameter_new(); - q->attribute = m_strdup(attribute); - q->value = m_strdup(value); - q->next = *p; - *p = q; + q = parameter_new(); + q->attribute = m_strdup(attribute); + q->value = m_strdup(value); + parameter_list_push(p, q); } void mutt_delete_parameter (const char *attribute, PARAMETER ** p) diff --git a/sendlib.c b/sendlib.c index e8a89a6..e92b825 100644 --- a/sendlib.c +++ b/sendlib.c @@ -274,7 +274,6 @@ static void encode_8bit (fgetconv_t * fc, FILE * fout, int istext) int mutt_write_mime_header (BODY * a, FILE * f) { - PARAMETER *p; char buffer[STRING]; char *t; char *fn; @@ -285,6 +284,8 @@ int mutt_write_mime_header (BODY * a, FILE * f) fprintf (f, "Content-Type: %s/%s", TYPE (a), a->subtype); if (a->parameter) { + PARAMETER *p; + len = 25 + m_strlen(a->subtype); /* approximate len. of content-type */ for (p = a->parameter; p; p = p->next) {