Fixed wxInputStream::Ungetch behaviour so that if you

a) unget a buffer (AAABBB)
b) read some data (AAA)
c) unget a second buffer (CCC)

it works OK now (you will get CCCBBB, instead of CCCAAABBB as before)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4870 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guillermo Rodriguez Garcia 1999-12-08 09:58:42 +00:00
parent aa51b2e153
commit 5ac8158ad9

View File

@ -494,23 +494,30 @@ wxInputStream::~wxInputStream()
char *wxInputStream::AllocSpaceWBack(size_t needed_size)
{
char *temp_b;
size_t old_size;
size_t toget;
old_size = m_wbacksize;
m_wbacksize += needed_size;
/* get number of bytes left from previous wback buffer */
toget = m_wbacksize - m_wbackcur;
if (!m_wback)
temp_b = (char *)malloc(m_wbacksize);
else
temp_b = (char *)realloc(m_wback, m_wbacksize);
/* allocate a buffer large enough to hold prev + new data */
temp_b = (char *) malloc(needed_size + toget);
if (!temp_b)
return (char*)NULL;
m_wback = temp_b;
return NULL;
memmove(m_wback+needed_size, m_wback, old_size);
return (char *)(m_wback);
/* copy previous data (and free old buffer) if needed */
if (m_wback)
{
memmove(temp_b + needed_size, m_wback + m_wbackcur, toget);
free(m_wback);
}
/* done */
m_wback = temp_b;
m_wbackcur = 0;
m_wbacksize = needed_size + toget;
return (char *) m_wback;
}
size_t wxInputStream::GetWBack(char *buf, size_t bsize)
@ -581,6 +588,7 @@ wxInputStream& wxInputStream::Read(void *buffer, size_t size)
size -= retsize;
buf += retsize;
// GRG: shouldn't we also add retsize to m_lastcount here?
m_lastcount = OnSysRead(buf, size);
return *this;
}