From: kawi Date: Fri, 16 Jan 2015 07:32:41 +0000 (+0100) Subject: unsigned/signed trouble X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=3735b4bd1c94eeec8bcf87286fcb4617156fe08d;p=crepublib unsigned/signed trouble --- diff --git a/base/ReByteBuffer.cpp b/base/ReByteBuffer.cpp index b45206b..c44ef3f 100644 --- a/base/ReByteBuffer.cpp +++ b/base/ReByteBuffer.cpp @@ -246,8 +246,8 @@ bool ReByteBuffer::endsWith(const Byte* tail, size_t tailLength, void ReByteBuffer::ensureSize(size_t size){ if (m_capacity < size){ int delta = m_delta > 0 ? m_delta - : 2 * m_capacity < - m_delta ? 2 * m_capacity : - m_delta; - if (size - m_capacity < delta) + : (int) m_capacity < - m_delta / 2 ? (int) 2 * m_capacity : - m_delta; + if (int(size - m_capacity) < delta) size = m_capacity + delta; // Think for the ending '\0': Byte* buffer = new Byte[size + 1]; diff --git a/base/ReByteBuffer.hpp b/base/ReByteBuffer.hpp index 1fbb0fe..aa6f891 100644 --- a/base/ReByteBuffer.hpp +++ b/base/ReByteBuffer.hpp @@ -173,7 +173,7 @@ public: } protected: // The minimum difference between old and new size after a new allocation. - size_t m_delta; + int m_delta; //@ If the needed space is small enough this buffer will be used. char m_primaryBuffer[PRIMARY_BUFFER_SIZE]; //@ The internal buffer. Points to m_primaryBuffer if the space is small enough. diff --git a/cunit/cuReByteBuffer.cpp b/cunit/cuReByteBuffer.cpp index 91d44d1..a97af5f 100644 --- a/cunit/cuReByteBuffer.cpp +++ b/cunit/cuReByteBuffer.cpp @@ -37,7 +37,7 @@ private: int maxDelta = 512 * (1 << 10); buf.setDelta(- maxDelta); int count = 0; - while(buf.capacity() < maxDelta){ + while(buf.capacity() < (size_t) maxDelta){ buf.ensureSize(buf.capacity() + 2); count++; }