mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Correct and simplify buf_shrink logic
svn:r4167
This commit is contained in:
parent
d6a6c8785b
commit
ad547cbb8c
@ -249,13 +249,13 @@ buf_shrink(buf_t *buf)
|
||||
{
|
||||
size_t new_len;
|
||||
|
||||
if (buf->highwater >= (buf->len<<2) && buf->len > MIN_LAZY_SHRINK_SIZE*2)
|
||||
return;
|
||||
|
||||
new_len = (buf->len>>1);
|
||||
new_len = buf->len;
|
||||
while (buf->highwater < (new_len>>2) && new_len > MIN_LAZY_SHRINK_SIZE*2)
|
||||
new_len >>= 1;
|
||||
|
||||
if (new_len == buf->len)
|
||||
return;
|
||||
|
||||
log_fn(LOG_DEBUG,"Shrinking buffer from %d to %d bytes.",
|
||||
(int)buf->len, (int)new_len);
|
||||
buf_resize(buf, new_len);
|
||||
|
Loading…
Reference in New Issue
Block a user