fpm zlog_stream_buf_alloc_ex little simplifications. (#8224)

This commit is contained in:
David CARLIER 2022-03-24 00:13:51 +00:00 committed by GitHub
parent e948d3c9c8
commit 814374faa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;