Open linjc0 opened 6 months ago
改成下面的方式,在运行过程中添加有效性判断 virtual int read(T *data, unsigned int size) { if (size > m_maxBufferSize) { size = m_maxBufferSize; }
unsigned int readDataSize = 0; while ((!isEmpty()) && (readDataSize < size)) { data[readDataSize] = m_buffer[m_head & (m_maxBufferSize - 1)]; ++readDataSize; m_head = (m_head + 1) & m_maxMirrorBufferIndex; } return readDataSize; }
目前的读取方式会遇到什么问题吗
改成下面的方式,在运行过程中添加有效性判断 virtual int read(T *data, unsigned int size) { if (size > m_maxBufferSize) { size = m_maxBufferSize; }