diff options
author | Bond_009 <bond.009@outlook.com> | 2022-01-02 12:11:54 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2022-01-13 00:48:19 +0100 |
commit | 1a310981826b800b1a4a405eaef0612cf7b1cb70 (patch) | |
tree | 869bc47f6ef261a4f7e9359b2808d685cc24c366 /src/ByteBuffer.cpp | |
parent | Suspicious packets: give 'em the silent treatment (#5375) (diff) | |
download | cuberite-1a310981826b800b1a4a405eaef0612cf7b1cb70.tar cuberite-1a310981826b800b1a4a405eaef0612cf7b1cb70.tar.gz cuberite-1a310981826b800b1a4a405eaef0612cf7b1cb70.tar.bz2 cuberite-1a310981826b800b1a4a405eaef0612cf7b1cb70.tar.lz cuberite-1a310981826b800b1a4a405eaef0612cf7b1cb70.tar.xz cuberite-1a310981826b800b1a4a405eaef0612cf7b1cb70.tar.zst cuberite-1a310981826b800b1a4a405eaef0612cf7b1cb70.zip |
Diffstat (limited to 'src/ByteBuffer.cpp')
-rw-r--r-- | src/ByteBuffer.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 127227180..80be9baee 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -117,8 +117,8 @@ bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count) size_t CurFreeSpace = GetFreeSpace(); #ifndef NDEBUG size_t CurReadableSpace = GetReadableSpace(); + size_t WrittenBytes = 0; #endif - size_t WrittenBytes = 0; if (CurFreeSpace < a_Count) { @@ -135,7 +135,9 @@ bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count) memcpy(m_Buffer + m_WritePos, Bytes, TillEnd); Bytes += TillEnd; a_Count -= TillEnd; - WrittenBytes = TillEnd; + #ifndef NDEBUG + WrittenBytes = TillEnd; + #endif } m_WritePos = 0; } @@ -145,7 +147,9 @@ bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count) { memcpy(m_Buffer + m_WritePos, Bytes, a_Count); m_WritePos += a_Count; - WrittenBytes += a_Count; + #ifndef NDEBUG + WrittenBytes += a_Count; + #endif } ASSERT(GetFreeSpace() == CurFreeSpace - WrittenBytes); |