diff options
| author | Brian Anderson <[email protected]> | 2011-01-07 22:13:52 -0500 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-01-10 11:31:32 -0800 |
| commit | 5f05ae68e555e94aa31c36b35dfb2e03952443ba (patch) | |
| tree | 191f1ce9c13211830426e3fec63dee59631e6766 /src/rt | |
| parent | Fix the check for growing the circular_buffer (diff) | |
| download | rust-5f05ae68e555e94aa31c36b35dfb2e03952443ba.tar.xz rust-5f05ae68e555e94aa31c36b35dfb2e03952443ba.zip | |
Don't allow circular_buffer to shrink below it's initial size
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/circular_buffer.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rt/circular_buffer.cpp b/src/rt/circular_buffer.cpp index 77509abb..8f12a115 100644 --- a/src/rt/circular_buffer.cpp +++ b/src/rt/circular_buffer.cpp @@ -121,13 +121,15 @@ circular_buffer::dequeue(void *dst) { } // Shrink if possible. - if (_buffer_sz >= INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz && + if (_buffer_sz > INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz && _unread <= _buffer_sz / 4) { dom->log(rust_log::MEM | rust_log::COMM, "circular_buffer is shrinking to %d bytes", _buffer_sz / 2); void *tmp = dom->malloc(_buffer_sz / 2); transfer(tmp); _buffer_sz >>= 1; + I(dom, _buffer_sz >= + next_power_of_two(INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz)); dom->free(_buffer); _buffer = (uint8_t *)tmp; _next = 0; |