From 65f9c5e8d026830b0fbd2583007c507e5e6e2b78 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Wed, 20 Oct 2004 09:12:17 +0000 Subject: (rfc2047e) Convenience: free the buffer ourselves rather than let the caller to it. svn path=/trunk/; revision=3952 --- rfc2047e.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rfc2047e.c b/rfc2047e.c index d42e3046..44f1ad0c 100644 --- a/rfc2047e.c +++ b/rfc2047e.c @@ -75,14 +75,23 @@ static char *encode_words(char *const *words, int nwords, const char *charset) return out; } +/** RFC-2047 encode string with given charset. Only the Q encoding + * (quoted-printable) supported at this time. + * WARNING: this code returns a static buffer! + */ char *rfc2047e(const char *string, const char *charset) { - char *t, *out; + static char *out; + char *t; const char *r; int count, minlen, idx, i; char **words = NULL; size_t l; assert(strlen(charset) < 40); + if (out) { + free(out); + out = NULL; + } /* phase 1: split original into words */ /* 1a: count, 1b: copy */ -- cgit v1.2.3