X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=imap%2Futf7.c;h=7eeed83fd4902d5634d532ff8c172db4ba080078;hp=95e8fd62aa3b12f4db08659224a0daf16b407dcf;hb=8e037c67a88cb4680c4391134c578e3b55a80f8a;hpb=c25bc063f35aaad6938c2022dae7a283346c2769 diff --git a/imap/utf7.c b/imap/utf7.c index 95e8fd6..7eeed83 100644 --- a/imap/utf7.c +++ b/imap/utf7.c @@ -11,6 +11,8 @@ # include "config.h" #endif +#include + #include "mutt.h" #include "charset.h" #include "imap_private.h" @@ -52,7 +54,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 == '&') { @@ -119,7 +121,7 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8, return buf; bail: - mem_free (&buf); + p_delete(&buf); return 0; } @@ -142,7 +144,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 +208,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7, } if (u8len) { - mem_free (&buf); + p_delete(&buf); return 0; } @@ -225,7 +227,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7, return buf; bail: - mem_free (&buf); + p_delete(&buf); return 0; } @@ -236,10 +238,10 @@ void imap_utf7_encode (char **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); } } @@ -249,7 +251,7 @@ void imap_utf7_decode (char **s) char *t = utf7_to_utf8 (*s, str_len (*s), 0, 0); if (t && !mutt_convert_string (&t, "UTF-8", Charset, 0)) { - mem_free (s); + p_delete(s); *s = t; } }