+ if (!m_persistent && m_buffer)
+ free(m_buffer);
+}
+
+bool wxMemoryStreamBase::ChangeBufferSize(size_t new_size)
+{
+ if (m_iolimit == 1)
+ return FALSE;
+
+ m_length = new_size;
+ if (!m_buffer)
+ m_buffer = (char *)malloc(m_length);
+ else
+ m_buffer = (char *)realloc(m_buffer, m_length);
+
+ return (m_buffer != NULL);
+}
+
+// ----------------------------------------------------------------------------
+// wxMemoryInputStream
+// ----------------------------------------------------------------------------
+
+wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len)
+{
+ m_persistent = TRUE;
+ m_length = len;
+ m_buffer = (char *)data; // It's bad.
+ m_position_i = 0;
+ m_lastread = 0;
+ m_eof = FALSE;
+ m_iolimit = 1;
+
+ m_i_streambuf->SetBufferIO(0);
+}
+
+wxMemoryInputStream::~wxMemoryInputStream()
+{
+}
+
+char wxMemoryInputStream::Peek()
+{
+ // wxStreamBuffer is disabled so just peek the current character.
+
+ return m_buffer[m_position_i];