]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/stream.cpp
add more virtual border drawing functions used by frame decorations code
[wxWidgets.git] / src / common / stream.cpp
index 07984617d2d268365da5c4367ecb73f733024165..f13da0d3d8af6a7e542f04eacde4bedfe4e82e8d 100644 (file)
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-  #pragma hdrstop
+    #pragma hdrstop
 #endif
 
+#if wxUSE_STREAMS
+
+#include "wx/stream.h"
+
 #ifndef WX_PRECOMP
-  #include "wx/defs.h"
+    #include "wx/log.h"
 #endif
 
-#if wxUSE_STREAMS
-
 #include <ctype.h>
-#include "wx/stream.h"
 #include "wx/datstrm.h"
 #include "wx/textfile.h"
-#include "wx/log.h"
 
 // ----------------------------------------------------------------------------
 // constants
@@ -117,7 +117,10 @@ wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer& buffer)
 void wxStreamBuffer::FreeBuffer()
 {
     if ( m_destroybuf )
+    {
         free(m_buffer_start);
+        m_buffer_start = NULL;
+    }
 }
 
 wxStreamBuffer::~wxStreamBuffer()
@@ -163,15 +166,15 @@ void wxStreamBuffer::SetBufferIO(void *start,
 
 void wxStreamBuffer::SetBufferIO(size_t bufsize)
 {
-    // start by freeing the old buffer
-    FreeBuffer();
-
     if ( bufsize )
     {
+        // this will free the old buffer and allocate the new one
         SetBufferIO(malloc(bufsize), bufsize, true /* take ownership */);
     }
     else // no buffer size => no buffer
     {
+        // still free the old one
+        FreeBuffer();
         InitBuffer();
     }
 }
@@ -664,7 +667,7 @@ size_t wxStreamBase::GetSize() const
         return 0;
 
     const size_t len = wx_truncate_cast(size_t, length);
-    wxASSERT_MSG( len == length, _T("large files not supported") );
+    wxASSERT_MSG( len == length + size_t(0), _T("large files not supported") );
 
     return len;
 }