From 916999aa35720bf4ea6bfeba46515ac7719fa519 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 19 Mar 2022 13:16:33 +0000 Subject: [PATCH] fpm zlog_stream_buf_alloc_ex little simplifications. --- sapi/fpm/fpm/zlog.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c index 0938f08e89de4..350d75d1952e6 100644 --- a/sapi/fpm/fpm/zlog.c +++ b/sapi/fpm/fpm/zlog.c @@ -286,14 +286,8 @@ static zlog_bool zlog_stream_buf_alloc_ex(struct zlog_stream *stream, size_t nee { char *buf; size_t size = stream->buf.size ?: stream->buf_init_size; - - if (stream->buf.data) { - size = MIN(zlog_limit, MAX(size * 2, needed)); - buf = realloc(stream->buf.data, size); - } else { - size = MIN(zlog_limit, MAX(size, needed)); - buf = malloc(size); - } + size = MIN(zlog_limit, MAX((stream->buf.data ? (size << 1) : size), needed)); + buf = realloc(stream->buf.data, size); if (buf == NULL) { return 0;