From ed963d568f42db5ada19b0f2777ace8f301a563d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 8 Apr 2017 10:09:36 +0100 Subject: [PATCH] [Minor] Use normal string allocation --- src/libmime/mime_headers.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c index b333fcdfe..e44b14eaa 100644 --- a/src/libmime/mime_headers.c +++ b/src/libmime/mime_headers.c @@ -465,6 +465,7 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in, gint encoding; gssize r; guint qmarks = 0; + gchar *ret; enum { parse_normal = 0, got_eqsign, @@ -478,9 +479,7 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in, c = in; p = in; end = in + inlen; - out = rspamd_mempool_alloc0 (pool, sizeof (*out)); - g_string_set_size (out, inlen); - out->len = 0; + out = g_string_sized_new (inlen); token = g_byte_array_sized_new (80); decoded = g_byte_array_sized_new (122); @@ -632,9 +631,10 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in, g_byte_array_free (token, TRUE); g_byte_array_free (decoded, TRUE); - rspamd_mempool_add_destructor (pool, g_free, out->str); + ret = g_string_free (out, FALSE); + rspamd_mempool_add_destructor (pool, g_free, ret); - return out->str; + return ret; } gchar * -- 2.39.5