Skip to content

Commit 814374f

Browse files
authored
fpm zlog_stream_buf_alloc_ex little simplifications. (#8224)
1 parent e948d3c commit 814374f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

sapi/fpm/fpm/zlog.c

+2-8
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,8 @@ static zlog_bool zlog_stream_buf_alloc_ex(struct zlog_stream *stream, size_t nee
286286
{
287287
char *buf;
288288
size_t size = stream->buf.size ?: stream->buf_init_size;
289-
290-
if (stream->buf.data) {
291-
size = MIN(zlog_limit, MAX(size * 2, needed));
292-
buf = realloc(stream->buf.data, size);
293-
} else {
294-
size = MIN(zlog_limit, MAX(size, needed));
295-
buf = malloc(size);
296-
}
289+
size = MIN(zlog_limit, MAX((stream->buf.data ? (size << 1) : size), needed));
290+
buf = realloc(stream->buf.data, size);
297291

298292
if (buf == NULL) {
299293
return 0;

0 commit comments

Comments
 (0)