Rocco Rutte:
[apps/madmutt.git] / rfc2231.c
index 3c0f097..c3986a4 100644 (file)
--- a/rfc2231.c
+++ b/rfc2231.c
@@ -22,6 +22,7 @@
 #endif
 
 #include "mutt.h"
+#include "ascii.h"
 #include "mime.h"
 #include "charset.h"
 #include "lib/str.h"
@@ -145,7 +146,7 @@ void rfc2231_decode_parameters (PARAMETER ** headp)
 
       p->attribute = NULL;
       p->value = NULL;
-      FREE (&p);
+      mem_free (&p);
 
       rfc2231_list_insert (&conthead, conttmp);
     }
@@ -164,15 +165,15 @@ void rfc2231_decode_parameters (PARAMETER ** headp)
 
 static struct rfc2231_parameter *rfc2231_new_parameter (void)
 {
-  return safe_calloc (sizeof (struct rfc2231_parameter), 1);
+  return mem_calloc (sizeof (struct rfc2231_parameter), 1);
 }
 
 static void rfc2231_free_parameter (struct rfc2231_parameter **p)
 {
   if (*p) {
-    FREE (&(*p)->attribute);
-    FREE (&(*p)->value);
-    FREE (p);
+    mem_free (&(*p)->attribute);
+    mem_free (&(*p)->value);
+    mem_free (p);
   }
 }
 
@@ -230,7 +231,7 @@ static void rfc2231_list_insert (struct rfc2231_parameter **list,
     q = p;
     p = p->next;
 
-    c = safe_strcmp (par->value, q->value);
+    c = str_cmp (par->value, q->value);
     if ((c > 0) || (c == 0 && par->index >= q->index))
       break;
   }
@@ -269,9 +270,9 @@ static void rfc2231_join_continuations (PARAMETER ** head,
       if (encoded && par->encoded)
         rfc2231_decode_one (par->value, valp);
 
-      vl = safe_strlen (par->value);
+      vl = str_len (par->value);
 
-      safe_realloc (&value, l + vl + 1);
+      mem_realloc (&value, l + vl + 1);
       strcpy (value + l, par->value);   /* __STRCPY_CHECKED__ */
       l += vl;
 
@@ -279,13 +280,13 @@ static void rfc2231_join_continuations (PARAMETER ** head,
       rfc2231_free_parameter (&par);
       if ((par = q))
         valp = par->value;
-    } while (par && !safe_strcmp (par->attribute, attribute));
+    } while (par && !str_cmp (par->attribute, attribute));
 
     if (value) {
       if (encoded)
         mutt_convert_string (&value, charset, Charset, M_ICONV_HOOK_FROM);
       *head = mutt_new_parameter ();
-      (*head)->attribute = safe_strdup (attribute);
+      (*head)->attribute = str_dup (attribute);
       (*head)->value = value;
       head = &(*head)->next;
     }
@@ -314,10 +315,10 @@ int rfc2231_encode_string (char **pd)
 
   if (!Charset || !SendCharset ||
       !(charset = mutt_choose_charset (Charset, SendCharset,
-                                       *pd, safe_strlen (*pd), &d, &dlen))) {
-    charset = safe_strdup (Charset ? Charset : "unknown-8bit");
+                                       *pd, str_len (*pd), &d, &dlen))) {
+    charset = str_dup (Charset ? Charset : "unknown-8bit");
     d = *pd;
-    dlen = safe_strlen (d);
+    dlen = str_len (d);
   }
 
   if (!mutt_is_us_ascii (charset))
@@ -330,9 +331,9 @@ int rfc2231_encode_string (char **pd)
       ++ext;
 
   if (encode) {
-    e = safe_malloc (dlen + 2 * ext + safe_strlen (charset) + 3);
+    e = mem_malloc (dlen + 2 * ext + str_len (charset) + 3);
     sprintf (e, "%s''", charset);       /* __SPRINTF_CHECKED__ */
-    t = e + safe_strlen (e);
+    t = e + str_len (e);
     for (s = d, slen = dlen; slen; s++, slen--)
       if (*s < 0x20 || *s >= 0x7f ||
           strchr (MimeSpecials, *s) || strchr ("*'%", *s)) {
@@ -344,16 +345,16 @@ int rfc2231_encode_string (char **pd)
     *t = '\0';
 
     if (d != *pd)
-      FREE (&d);
-    FREE (pd);
+      mem_free (&d);
+    mem_free (pd);
     *pd = e;
   }
   else if (d != *pd) {
-    FREE (pd);
+    mem_free (pd);
     *pd = d;
   }
 
-  FREE (&charset);
+  mem_free (&charset);
 
   return encode;
 }