From 3735b4bd1c94eeec8bcf87286fcb4617156fe08d Mon Sep 17 00:00:00 2001 From: kawi Date: Fri, 16 Jan 2015 08:32:41 +0100 Subject: [PATCH] unsigned/signed trouble --- base/ReByteBuffer.cpp | 4 ++-- base/ReByteBuffer.hpp | 2 +- cunit/cuReByteBuffer.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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++; } -- 2.39.5