fix (streams): fixed bug in max readable bytes calculation
This commit is contained in:
parent
1777ca2150
commit
aa5ca306ca
|
@ -47,11 +47,11 @@ uint32_t stream_read(stream_T* stream, void* buffer_out, uint32_t n) {
|
|||
uint32_t num_bottom;
|
||||
|
||||
if (stream->pos_sender > stream->pos_receiver) {
|
||||
num_top = MIN(n, stream->pos_sender - stream->pos_receiver - 1);
|
||||
num_top = MIN(n, stream->pos_sender - stream->pos_receiver);
|
||||
num_bottom = 0;
|
||||
} else {
|
||||
num_top = MIN(n, stream->size - stream->pos_receiver);
|
||||
num_bottom = MIN(n - num_top, stream->pos_sender - 1);
|
||||
num_bottom = MIN(n - num_top, stream->pos_sender);
|
||||
}
|
||||
|
||||
memory_copy(&stream->buffer[stream->pos_receiver], buffer_out, num_top);
|
||||
|
|
Loading…
Reference in New Issue