diff options
author | Benoit Foucher <benoit@zeroc.com> | 2013-01-23 14:36:10 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2013-01-23 14:36:10 +0100 |
commit | 66bf1a7f2d0d46281ebf3d62caab6b9158eaa8a0 (patch) | |
tree | bd6aca447179f8d2e586c12cb961d683552504be /cpp/src/Ice/Buffer.cpp | |
parent | Minor code style fixes (diff) | |
download | ice-66bf1a7f2d0d46281ebf3d62caab6b9158eaa8a0.tar.bz2 ice-66bf1a7f2d0d46281ebf3d62caab6b9158eaa8a0.tar.xz ice-66bf1a7f2d0d46281ebf3d62caab6b9158eaa8a0.zip |
Fix for ICE-4841 - added no copy option when creating input stream
Diffstat (limited to 'cpp/src/Ice/Buffer.cpp')
-rw-r--r-- | cpp/src/Ice/Buffer.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/cpp/src/Ice/Buffer.cpp b/cpp/src/Ice/Buffer.cpp index bed4c088b92..ec1fdf6730a 100644 --- a/cpp/src/Ice/Buffer.cpp +++ b/cpp/src/Ice/Buffer.cpp @@ -30,14 +30,28 @@ IceInternal::Buffer::Container::Container(size_type maxCapacity) : { } +IceInternal::Buffer::Container::Container(const_iterator beg, const_iterator end) : + _buf(const_cast<iterator>(beg)), + _size(end - beg), + _capacity(0), + _maxCapacity(0), + _shrinkCounter(0) +{ +} + IceInternal::Buffer::Container::~Container() { - ::free(_buf); + if(_buf && _capacity > 0) + { + ::free(_buf); + } } void IceInternal::Buffer::Container::swap(Container& other) { + assert(!_buf || _capacity > 0); + std::swap(_buf, other._buf); std::swap(_size, other._size); @@ -48,6 +62,8 @@ IceInternal::Buffer::Container::swap(Container& other) void IceInternal::Buffer::Container::clear() { + assert(!_buf || _capacity > 0); + free(_buf); _buf = 0; _size = 0; @@ -57,6 +73,8 @@ IceInternal::Buffer::Container::clear() void IceInternal::Buffer::Container::reserve(size_type n) { + assert(!_buf || _capacity > 0); + size_type c = _capacity; if(n > _capacity) { |