mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-04-05 22:46:59 +00:00
Sanity check the ring buffers.
This commit is contained in:
parent
a381387c5c
commit
0c635f5132
6 changed files with 24 additions and 10 deletions
13
SampleRB.cpp
13
SampleRB.cpp
|
|
@ -35,12 +35,19 @@ m_overflow(false)
|
|||
|
||||
uint16_t CSampleRB::getSpace() const
|
||||
{
|
||||
uint16_t n = 0U;
|
||||
|
||||
if (m_tail == m_head)
|
||||
return m_full ? 0U : m_length;
|
||||
n = m_full ? 0U : m_length;
|
||||
else if (m_tail < m_head)
|
||||
return m_length - m_head + m_tail;
|
||||
n = m_length - m_head + m_tail;
|
||||
else
|
||||
return m_tail - m_head;
|
||||
n = m_tail - m_head;
|
||||
|
||||
if (n > m_length)
|
||||
n = 0U;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
uint16_t CSampleRB::getData() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue