remove yet anoter round of str_* functions, replaced with their inlineable
[apps/madmutt.git] / imap / utf7.c
index 95e8fd6..76ea696 100644 (file)
 # include "config.h"
 #endif
 
+#include <lib-lib/mem.h>
+
 #include "mutt.h"
 #include "charset.h"
 #include "imap_private.h"
 
-#include "lib/mem.h"
-
 static int Index_64[128] = {
   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -52,7 +52,7 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8,
   char *buf, *p;
   int b, ch, k;
 
-  p = buf = mem_malloc (u7len + u7len / 8 + 1);
+  p = buf = p_new(char, u7len + u7len / 8 + 1);
 
   for (; u7len; u7++, u7len--) {
     if (*u7 == '&') {
@@ -113,13 +113,13 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8,
   if (u8len)
     *u8len = p - buf;
 
-  mem_realloc (&buf, p - buf);
+  p_realloc(&buf, p - buf);
   if (u8)
     *u8 = buf;
   return buf;
 
 bail:
-  mem_free (&buf);
+  p_delete(&buf);
   return 0;
 }
 
@@ -142,7 +142,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
    * In the worst case we convert 2 chars to 7 chars. For example:
    * "\x10&\x10&..." -> "&ABA-&-&ABA-&-...".
    */
-  p = buf = mem_malloc ((u8len / 2) * 7 + 6);
+  p = buf = p_new(char, (u8len / 2) * 7 + 6);
 
   while (u8len) {
     unsigned char c = *u8;
@@ -206,7 +206,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
   }
 
   if (u8len) {
-    mem_free (&buf);
+    p_delete(&buf);
     return 0;
   }
 
@@ -219,37 +219,37 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
   *p++ = '\0';
   if (u7len)
     *u7len = p - buf;
-  mem_realloc (&buf, p - buf);
+  p_realloc(&buf, p - buf);
   if (u7)
     *u7 = buf;
   return buf;
 
 bail:
-  mem_free (&buf);
+  p_delete(&buf);
   return 0;
 }
 
 void imap_utf7_encode (char **s)
 {
   if (Charset) {
-    char *t = str_dup (*s);
+    char *t = m_strdup(*s);
 
     if (!mutt_convert_string (&t, Charset, "UTF-8", 0)) {
       char *u7 = utf8_to_utf7 (t, strlen (t), NULL, 0);
-      mem_free (s);
+      p_delete(s);
       *s = u7;
     }
-    mem_free (&t);
+    p_delete(&t);
   }
 }
 
 void imap_utf7_decode (char **s)
 {
   if (Charset) {
-    char *t = utf7_to_utf8 (*s, str_len (*s), 0, 0);
+    char *t = utf7_to_utf8 (*s, m_strlen(*s), 0, 0);
 
     if (t && !mutt_convert_string (&t, "UTF-8", Charset, 0)) {
-      mem_free (s);
+      p_delete(s);
       *s = t;
     }
   }