Skip to content

Commit

Permalink
lib: Optimization - p_strconcat() doesn't need to allocate from data …
Browse files Browse the repository at this point in the history
…stack

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.
  • Loading branch information
sirainen committed Dec 16, 2016
1 parent 7e90e94 commit 19b9eb5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/lib/strfuncs.c
Expand Up @@ -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);
Expand Down

0 comments on commit 19b9eb5

Please sign in to comment.