added wxStreamBuffer::Truncate() (patch 1687081)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -81,6 +81,7 @@ All:
|
|||||||
- Implemented wxMemoryInputStream::CanRead()
|
- Implemented wxMemoryInputStream::CanRead()
|
||||||
- Added wxEXEC_BLOCK flag (Hank Schultz)
|
- Added wxEXEC_BLOCK flag (Hank Schultz)
|
||||||
- Add support for wxStream-derived classes to wxRTTI (Stas Sergeev)
|
- Add support for wxStream-derived classes to wxRTTI (Stas Sergeev)
|
||||||
|
- Added wxStreamBuffer::Truncate() (Stas Sergeev)
|
||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
|
@@ -184,6 +184,17 @@ the beginning of the stream. Otherwise, it returns wxInvalidOffset.
|
|||||||
|
|
||||||
Resets to the initial state variables concerning the buffer.
|
Resets to the initial state variables concerning the buffer.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxStreamBuffer::Truncate}\label{wxstreambuffertruncate}
|
||||||
|
|
||||||
|
\func{void}{Truncate}{\void}
|
||||||
|
|
||||||
|
Truncates the buffer to the current position.
|
||||||
|
|
||||||
|
Note: Truncate() cannot be used to enlarge the buffer. This is
|
||||||
|
usually not needed since the buffer expands automatically.
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxStreamBuffer::SetBufferIO}\label{wxstreambuffersetbufferio}
|
\membersection{wxStreamBuffer::SetBufferIO}\label{wxstreambuffersetbufferio}
|
||||||
|
|
||||||
\func{void}{SetBufferIO}{\param{char*}{ buffer\_start}, \param{char*}{ buffer\_end}}
|
\func{void}{SetBufferIO}{\param{char*}{ buffer\_start}, \param{char*}{ buffer\_end}}
|
||||||
|
@@ -434,6 +434,7 @@ public:
|
|||||||
|
|
||||||
// Buffer control
|
// Buffer control
|
||||||
void ResetBuffer();
|
void ResetBuffer();
|
||||||
|
void Truncate();
|
||||||
|
|
||||||
// NB: the buffer must always be allocated with malloc() if takeOwn is
|
// NB: the buffer must always be allocated with malloc() if takeOwn is
|
||||||
// true as it will be deallocated by free()
|
// true as it will be deallocated by free()
|
||||||
|
@@ -192,6 +192,28 @@ void wxStreamBuffer::ResetBuffer()
|
|||||||
: m_buffer_start;
|
: m_buffer_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxStreamBuffer::Truncate()
|
||||||
|
{
|
||||||
|
size_t new_size = m_buffer_pos - m_buffer_start;
|
||||||
|
if ( new_size == m_buffer_size )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( !new_size )
|
||||||
|
{
|
||||||
|
FreeBuffer();
|
||||||
|
InitBuffer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *new_start = (char *)realloc(m_buffer_start, new_size);
|
||||||
|
wxCHECK_RET( new_size, _T("shrinking buffer shouldn't fail") );
|
||||||
|
|
||||||
|
m_buffer_start = new_start;
|
||||||
|
m_buffer_size = new_size;
|
||||||
|
m_buffer_end = m_buffer_start + m_buffer_size;
|
||||||
|
m_buffer_pos = m_buffer_end;
|
||||||
|
}
|
||||||
|
|
||||||
// fill the buffer with as much data as possible (only for read buffers)
|
// fill the buffer with as much data as possible (only for read buffers)
|
||||||
bool wxStreamBuffer::FillBuffer()
|
bool wxStreamBuffer::FillBuffer()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user