- SF#3540497 HashMap iterator crash in VS 2010

- allow Buffer resize to zero
This commit is contained in:
Aleksandar Fabijanic
2012-08-04 03:49:51 +00:00
parent b2b18b07a5
commit 5cade11ba6
4 changed files with 30 additions and 13 deletions

View File

@@ -126,10 +126,12 @@ public:
}
void resize(std::size_t newCapacity, bool preserveContent = true)
/// Resizes the buffer. If preserveContent is true,
/// Resizes the buffer capacity and size. If preserveContent is true,
/// the content of the old buffer is copied over to the
/// new buffer. The new capacity can be larger or smaller than
/// the current one, but it must not be 0.
/// the current one; if it is smaller, capacity will remain intact.
/// Size will always be set to the new capacity.
///
/// Buffers only wrapping externally owned storage can not be
/// resized. If resize is attempted on those, IllegalAccessException
/// is thrown.
@@ -137,8 +139,6 @@ public:
if (!_ownMem)
throw Poco::InvalidAccessException("Cannot resize buffer which does not own its storage.");
poco_assert(newCapacity);
if (newCapacity > _capacity)
{
T* ptr = new T[newCapacity];