Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibuffer read有效性判断 #88

Open
linjc0 opened this issue May 31, 2024 · 1 comment
Open

ibuffer read有效性判断 #88

linjc0 opened this issue May 31, 2024 · 1 comment

Comments

@linjc0
Copy link

linjc0 commented May 31, 2024

改成下面的方式,在运行过程中添加有效性判断
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;
}
@itas109
Copy link
Owner

itas109 commented Jun 1, 2024

目前的读取方式会遇到什么问题吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants