mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 04:56:58 +00:00
Fix the check for growing the circular_buffer
This commit is contained in:
parent
32c1c9f55c
commit
04056d89c8
@ -62,7 +62,7 @@ circular_buffer::enqueue(void *src) {
|
||||
I(dom, _unread <= _buffer_sz);
|
||||
|
||||
// Grow if necessary.
|
||||
if (_unread == _buffer_sz) {
|
||||
if (_unread + unit_sz > _buffer_sz) {
|
||||
size_t new_buffer_sz = _buffer_sz << 1;
|
||||
I(dom, new_buffer_sz <= MAX_CIRCULAR_BUFFFER_SIZE);
|
||||
void *new_buffer = dom->malloc(new_buffer_sz);
|
||||
|
@ -25,8 +25,22 @@ impure fn test_init() {
|
||||
mychan <| val;
|
||||
}
|
||||
|
||||
// Dump lots of items into the channel so it has to grow.
|
||||
// Don't trigger any assertions.
|
||||
impure fn test_grow() {
|
||||
let port[record] myport = port();
|
||||
auto mychan = chan(myport);
|
||||
|
||||
let record val = rec(val1=0i32, val2=0i32, val3=0i32);
|
||||
|
||||
for each (uint i in _uint.range(0u, 100u)) {
|
||||
mychan <| val;
|
||||
}
|
||||
}
|
||||
|
||||
impure fn main() {
|
||||
test_init();
|
||||
test_grow();
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
Loading…
Reference in New Issue
Block a user