]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Optimization - p_strconcat() doesn't need to allocate from data stack
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Dec 2016 03:16:28 +0000 (05:16 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 16 Dec 2016 21:41:28 +0000 (23:41 +0200)
Various other parts of the code already rely on p_malloc() not overwriting
t_buffer_get()'ed data. p_strconcat() can do that as well.

src/lib/strfuncs.c

index 266be153c49183970d8a02054375575241bfd2f2..0fa45beeb27cffd0495dccfc33239520d35560df 100644 (file)
@@ -217,12 +217,9 @@ char *p_strconcat(pool_t pool, const char *str1, ...)
                ret = vstrconcat(str1, args, &len);
                t_buffer_alloc(len);
        } else {
-               T_BEGIN {
-                       temp = vstrconcat(str1, args, &len);
-                       t_buffer_alloc(len);
-                       ret = p_malloc(pool, len);
-                       memcpy(ret, temp, len);
-               } T_END;
+               temp = vstrconcat(str1, args, &len);
+               ret = p_malloc(pool, len);
+               memcpy(ret, temp, len);
        }
 
        va_end(args);