summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Buffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/Buffer.cpp')
-rw-r--r--cpp/src/Ice/Buffer.cpp20
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)
{