Fixed an obvious bug, simplified a bit the code

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2470 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2003-01-17 12:32:09 +00:00
parent 089f7debba
commit 51ee67dc8f
1 changed files with 4 additions and 5 deletions

View File

@ -123,17 +123,16 @@ BBufferIO::ReadAt(off_t pos, void *buffer, size_t size)
|| pos > m_buffer_start + m_buffer_used)
{
// ...cache as much as we can from the stream
ssize_t readSize = m_stream->ReadAt(pos, m_buffer, m_buffer_phys);
m_buffer_used += readSize;
if (readSize > 0)
m_buffer_used = m_stream->ReadAt(pos, m_buffer, m_buffer_phys);
if (m_buffer_used > 0)
m_buffer_start = pos; // The data is buffered starting from this offset
}
size = min_c(size, m_buffer_used);
// copy data from the cache to the given buffer
memcpy(buffer, m_buffer + pos, size);
memcpy(buffer, m_buffer + pos - m_buffer_start, size);
return size;
}