From: Lennart Poettering Date: Wed, 6 Jan 2021 16:23:38 +0000 (+0100) Subject: string-util: use GREEDY_ALLOC_ROUND_UP() in strextend() X-Git-Tag: v248-rc1~425^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2a4e1fd0d498824f31292d8ba4e1e97c05eef0b8;p=thirdparty%2Fsystemd.git string-util: use GREEDY_ALLOC_ROUND_UP() in strextend() This uses GREEDY_ALLOC_ROUND_UP() to grow the allocation size exponentially. This should speed allocation loops up a bit, given that we often call strextend() repeatedly in a loop on the same buffer. --- diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 105952156d7..be42d5c4f5d 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -830,7 +830,7 @@ char *strextend_with_separator_internal(char **x, const char *separator, ...) { need_separator = !isempty(*x); - nr = realloc(*x, l+1); + nr = realloc(*x, GREEDY_ALLOC_ROUND_UP(l+1)); if (!nr) return NULL;