use more ad-hoc list handling function, and avoid to muck with ->next
authorPierre Habouzit <madcoder@debian.org>
Wed, 15 Nov 2006 12:05:33 +0000 (13:05 +0100)
committerPierre Habouzit <madcoder@debian.org>
Wed, 15 Nov 2006 12:05:33 +0000 (13:05 +0100)
pointer ourselves

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
commands.c
hcache.c
lib-mime/rfc2231.c
muttlib.c
sendlib.c

index 2054d12..bc05999 100644 (file)
@@ -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];
   char buf[LONG_STRING];
   char obuf[LONG_STRING];
   char tmp[STRING];
-  PARAMETER *p;
 
   char charset[STRING];
   char *cp;
 
   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) {
   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) {
     ssize_t l;
 
     for (p = b->parameter; p; p = p->next) {
index 8560ef6..da3d6bb 100644 (file)
--- 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) {
   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--;
   }
     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)
 }
 
 static unsigned char *dump_body (BODY * c, unsigned char *d, int *off)
index bf05bef..b5a2553 100644 (file)
@@ -140,9 +140,8 @@ static void purge_empty_parameters(PARAMETER **headp)
         PARAMETER *p = *headp;
 
         if (!p->attribute || !p->value) {
         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;
         }
         } else {
             headp = &(*headp)->next;
         }
index fbd4564..d607b4f 100644 (file)
--- 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)
 {
 
 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)
 {
 }
 
 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)
 }
 
 void mutt_delete_parameter (const char *attribute, PARAMETER ** p)
index e8a89a6..e92b825 100644 (file)
--- 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)
 {
 
 int mutt_write_mime_header (BODY * a, FILE * f)
 {
-  PARAMETER *p;
   char buffer[STRING];
   char *t;
   char *fn;
   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) {
   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) {
     len = 25 + m_strlen(a->subtype);        /* approximate len. of content-type */
 
     for (p = a->parameter; p; p = p->next) {