From: Guilhem Lavaux Date: Sun, 10 Oct 1999 11:36:39 +0000 (+0000) Subject: Changed Ungetch behaviour (FIFO -> LIFO). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/783ff666e0bcef3efda44fa4f4badbc76364ce25 Changed Ungetch behaviour (FIFO -> LIFO). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3912 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/stream.cpp b/src/common/stream.cpp index 162dcf19cb..6698b43ad8 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -480,7 +480,9 @@ wxInputStream::~wxInputStream() char *wxInputStream::AllocSpaceWBack(size_t needed_size) { char *temp_b; + size_t old_size; + old_size = m_wbacksize; m_wbacksize += needed_size; if (!m_wback) @@ -491,13 +493,16 @@ char *wxInputStream::AllocSpaceWBack(size_t needed_size) if (!temp_b) return NULL; m_wback = temp_b; + m_wbackcur += needed_size; + + memmove(m_wback+needed_size, m_wback, old_size); - return (char *)(m_wback+(m_wbacksize-needed_size)); + return (char *)(m_wback); } size_t wxInputStream::GetWBack(char *buf, size_t bsize) { - size_t s_toget = m_wbacksize-m_wbackcur; + size_t s_toget = m_wbackcur; if (!m_wback) return 0; @@ -505,10 +510,10 @@ size_t wxInputStream::GetWBack(char *buf, size_t bsize) if (bsize < s_toget) s_toget = bsize; - memcpy(buf, (m_wback+m_wbackcur), s_toget); + memcpy(buf, (m_wback+m_wbackcur-bsize), s_toget); - m_wbackcur += s_toget; - if (m_wbackcur == m_wbacksize) { + m_wbackcur -= s_toget; + if (m_wbackcur == 0) { free(m_wback); m_wback = (char *)NULL; m_wbacksize = 0;