diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 743e19224..e11ce838d 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -137,26 +137,26 @@ Buffer::Buffer () : m_data (Buffer::Create ()), m_zeroAreaSize (0), m_start (m_maxTotalAddStart), - m_size (0) + m_end (0) { - if (m_start > m_data->m_size) + if (m_end > m_data->m_size) { - m_start = 0; + m_end = 0; } - NS_ASSERT (m_start <= m_data->m_size); + NS_ASSERT (m_end <= m_data->m_size); } Buffer::Buffer (uint32_t dataSize) : m_data (Buffer::Create ()), m_zeroAreaSize (dataSize), m_start (m_maxTotalAddStart), - m_size (0) + m_end (0) { - if (m_start > m_data->m_size) + if (m_end > m_data->m_size) { - m_start = 0; + m_end = 0; } - NS_ASSERT (m_start <= m_data->m_size); + NS_ASSERT (m_end <= m_data->m_size); } @@ -164,7 +164,7 @@ Buffer::Buffer (Buffer const&o) : m_data (o.m_data), m_zeroAreaSize (o.m_zeroAreaSize), m_start (o.m_start), - m_size (o.m_size) + m_end (o.m_end) { m_data->m_count++; NS_ASSERT (m_start <= m_data->m_size); @@ -186,7 +186,7 @@ Buffer::operator = (Buffer const&o) } m_zeroAreaSize = o.m_zeroAreaSize; m_start = o.m_start; - m_size = o.m_size; + m_end = o.m_end; NS_ASSERT (m_start <= m_data->m_size); return *this; } @@ -210,7 +210,7 @@ Buffer::GetStart (void) const uint32_t Buffer::GetSize (void) const { - return m_size + m_zeroAreaSize; + return m_end + m_zeroAreaSize; } Buffer::Iterator @@ -579,23 +579,23 @@ Buffer::AddAtStart (uint32_t start) { /* enough space in the buffer and not dirty. */ m_start -= start; - m_size += start; + m_end += start; } - else if (m_size + start <= m_data->m_size && !isDirty) + else if (m_end + start <= m_data->m_size && !isDirty) { /* enough space but need to move data around to fit new data */ - memmove (m_data->m_data + start, GetStart (), m_size); + memmove (m_data->m_data + start, GetStart (), m_end); NS_ASSERT (start > m_start); m_data->m_initialStart += start - m_start; m_start = 0; - m_size += start; + m_end += start; } else if (m_start < start) { /* not enough space in buffer */ - uint32_t newSize = m_size + start; + uint32_t newSize = m_end + start; struct Buffer::BufferData *newData = Buffer::Allocate (newSize, 0); - memcpy (newData->m_data + start, GetStart (), m_size); + memcpy (newData->m_data + start, GetStart (), m_end); newData->m_initialStart = m_data->m_initialStart + start; m_data->m_count--; if (m_data->m_count == 0) @@ -604,14 +604,14 @@ Buffer::AddAtStart (uint32_t start) } m_data = newData; m_start = 0; - m_size = newSize; + m_end = newSize; } else { /* enough space in the buffer but it is dirty ! */ NS_ASSERT (isDirty); struct Buffer::BufferData *newData = Buffer::Create (); - memcpy (newData->m_data + m_start, GetStart (), m_size); + memcpy (newData->m_data + m_start, GetStart (), m_end); newData->m_initialStart = m_data->m_initialStart; m_data->m_count--; if (m_data->m_count == 0) @@ -620,11 +620,11 @@ Buffer::AddAtStart (uint32_t start) } m_data = newData; m_start -= start; - m_size += start; + m_end += start; } // update dirty area m_data->m_dirtyStart = m_start; - m_data->m_dirtySize = m_size; + m_data->m_dirtySize = m_end; // update m_maxTotalAddStart uint32_t addedAtStart; if (m_data->m_initialStart > m_start) @@ -639,7 +639,7 @@ Buffer::AddAtStart (uint32_t start) { m_maxTotalAddStart = addedAtStart; } - NS_DEBUG ("start add="<