add adjustment report to overloaded Buffer::AddAtEnd method

This commit is contained in:
Mathieu Lacage
2008-04-23 09:11:55 -07:00
parent ad54b2ce62
commit 4a78ce68d1
2 changed files with 18 additions and 3 deletions

View File

@@ -434,9 +434,10 @@ Buffer::AddAtEnd (uint32_t end)
return delta;
}
void
int32_t
Buffer::AddAtEnd (const Buffer &o)
{
int32_t orgStart = m_start;
if (m_end == m_zeroAreaEnd &&
o.m_start == o.m_zeroAreaStart &&
o.m_zeroAreaEnd - o.m_zeroAreaStart > 0)
@@ -456,7 +457,7 @@ Buffer::AddAtEnd (const Buffer &o)
Buffer::Iterator src = o.End ();
src.Prev (endData);
dst.Write (src, o.End ());
return;
return m_start - orgStart;
}
Buffer dst = CreateFullCopy ();
Buffer src = o.CreateFullCopy ();
@@ -466,6 +467,7 @@ Buffer::AddAtEnd (const Buffer &o)
destStart.Prev (src.GetSize ());
destStart.Write (src.Begin (), src.End ());
*this = dst;
return m_start - orgStart;
}
void

View File

@@ -423,7 +423,20 @@ public:
*/
int32_t AddAtEnd (uint32_t end);
void AddAtEnd (const Buffer &o);
/**
* \param o the buffer to append to the end of this buffer.
* \returns the adjustment delta.
*
* Add bytes at the end of the Buffer.
* Any call to this method invalidates any Iterator
* pointing to this Buffer.
*
* The value returned by this method indicates how the internal
* buffer was modified to handle the user request to reserve space.
* If that value is zero, the buffer was not modified: the user
* request was completed without further memory allocation.
*/
int32_t AddAtEnd (const Buffer &o);
/**
* \param start size to remove
*