about summary refs log tree commit diff
path: root/src/rt/circular_buffer.cpp
diff options
context:
space:
mode:
authorBrian Anderson <andersrb@gmail.com>2011-01-07 22:13:52 -0500
committerGraydon Hoare <graydon@mozilla.com>2011-01-10 11:31:32 -0800
commit5f05ae68e555e94aa31c36b35dfb2e03952443ba (patch)
tree191f1ce9c13211830426e3fec63dee59631e6766 /src/rt/circular_buffer.cpp
parent04056d89c831767f3c71a0cc274e7c17b5721734 (diff)
downloadrust-5f05ae68e555e94aa31c36b35dfb2e03952443ba.tar.gz
rust-5f05ae68e555e94aa31c36b35dfb2e03952443ba.zip
Don't allow circular_buffer to shrink below it's initial size
Diffstat (limited to 'src/rt/circular_buffer.cpp')
-rw-r--r--src/rt/circular_buffer.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rt/circular_buffer.cpp b/src/rt/circular_buffer.cpp
index 77509abb069..8f12a1154a5 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;