projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
drop mem_alloc and mem_free, use my own hand crafted optmized macros that
[apps/madmutt.git]
/
imap
/
utf7.c
diff --git
a/imap/utf7.c
b/imap/utf7.c
index
95e8fd6
..
7eeed83
100644
(file)
--- a/
imap/utf7.c
+++ b/
imap/utf7.c
@@
-11,6
+11,8
@@
# include "config.h"
#endif
# include "config.h"
#endif
+#include <lib-lib/mem.h>
+
#include "mutt.h"
#include "charset.h"
#include "imap_private.h"
#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;
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 == '&') {
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:
return buf;
bail:
-
mem_free
(&buf);
+
p_delete
(&buf);
return 0;
}
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-&-...".
*/
* 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;
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) {
}
if (u8len) {
-
mem_free
(&buf);
+
p_delete
(&buf);
return 0;
}
return 0;
}
@@
-225,7
+227,7
@@
static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
return buf;
bail:
return buf;
bail:
-
mem_free
(&buf);
+
p_delete
(&buf);
return 0;
}
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);
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;
}
*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)) {
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;
}
}
*s = t;
}
}