diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-05-01 20:50:40 +0200 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-05-01 20:50:40 +0200 |
commit | 8780b324ff075f17358b01bc3615da0397fbe8be (patch) | |
tree | d448ab665fd50cca3861e06654f8668a89c8d953 /src/ByteBuffer.cpp | |
parent | Added Testing capability (diff) | |
parent | Fixed MSVC2013 compilation. (diff) | |
download | cuberite-8780b324ff075f17358b01bc3615da0397fbe8be.tar cuberite-8780b324ff075f17358b01bc3615da0397fbe8be.tar.gz cuberite-8780b324ff075f17358b01bc3615da0397fbe8be.tar.bz2 cuberite-8780b324ff075f17358b01bc3615da0397fbe8be.tar.lz cuberite-8780b324ff075f17358b01bc3615da0397fbe8be.tar.xz cuberite-8780b324ff075f17358b01bc3615da0397fbe8be.tar.zst cuberite-8780b324ff075f17358b01bc3615da0397fbe8be.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ByteBuffer.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index c634dc308..c27bc4cad 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -171,7 +171,7 @@ cByteBuffer::~cByteBuffer() -bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count) +bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count) { CHECK_THREAD; CheckValid(); @@ -187,13 +187,14 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count) } ASSERT(m_BufferSize >= m_WritePos); size_t TillEnd = m_BufferSize - m_WritePos; + const char * Bytes = (const char *)a_Bytes; if (TillEnd <= a_Count) { // Need to wrap around the ringbuffer end if (TillEnd > 0) { - memcpy(m_Buffer + m_WritePos, a_Bytes, TillEnd); - a_Bytes += TillEnd; + memcpy(m_Buffer + m_WritePos, Bytes, TillEnd); + Bytes += TillEnd; a_Count -= TillEnd; WrittenBytes = TillEnd; } @@ -203,7 +204,7 @@ bool cByteBuffer::Write(const char * a_Bytes, size_t a_Count) // We're guaranteed that we'll fit in a single write op if (a_Count > 0) { - memcpy(m_Buffer + m_WritePos, a_Bytes, a_Count); + memcpy(m_Buffer + m_WritePos, Bytes, a_Count); m_WritePos += a_Count; WrittenBytes += a_Count; } @@ -887,9 +888,7 @@ void cByteBuffer::AdvanceReadPos(size_t a_Count) void cByteBuffer::CheckValid(void) const { - ASSERT(m_ReadPos >= 0); ASSERT(m_ReadPos < m_BufferSize); - ASSERT(m_WritePos >= 0); ASSERT(m_WritePos < m_BufferSize); } |