gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/rtmp r9742: resize a partially populated b


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9742: resize a partially populated buffer correctly when the seekptr isn't incremented.
Date: Mon, 17 Nov 2008 19:55:44 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9742
committer: address@hidden
branch nick: rtmp
timestamp: Mon 2008-11-17 19:55:44 -0700
message:
  resize a partially populated buffer correctly when the seekptr isn't 
incremented.
modified:
  libamf/buffer.cpp
  libamf/buffer.h
=== modified file 'libamf/buffer.cpp'
--- a/libamf/buffer.cpp 2008-11-01 15:15:52 +0000
+++ b/libamf/buffer.cpp 2008-11-18 02:55:44 +0000
@@ -633,14 +633,24 @@
            return *this;
        }
 
-       // Cache the number of bytes currently being held
-       size_t used = _seekptr - _data.get();
+       // check the sizes. If we had data read using ->reference(), the 
seekptr isn't
+       // increased, so in these cases we just copy al lthe data blindly, as 
it's
+       // better than loosing data.
+       size_t used = 0;
+       if (_seekptr != _data.get()) {
+           used = _seekptr - _data.get();
+       } else {
+           if (size < _nbytes) {
+               used = size;
+           } else {
+               used = _nbytes;
+           }
+       }
+       
        
        // Copy the existing data into the new block of memory. The data
        // held currently is moved to the temporary array, and then gets
        // deleted when this method returns.
-//     tmp.swap(_data);
-       
        // We loose data if we resize smaller than the data currently held.
        if (size < used) {
            log_error("Truncating data (%d bytes) while resizing!", used - 
size);

=== modified file 'libamf/buffer.h'
--- a/libamf/buffer.h   2008-10-27 18:37:05 +0000
+++ b/libamf/buffer.h   2008-11-18 02:55:44 +0000
@@ -82,7 +82,7 @@
     /// \brief Test to see if the buffer has any data.
     ///
     /// @return true or false
-    bool empty() { return (_seekptr)?true:false; };
+    bool empty() { return (_seekptr) ? true : false; };
 
     /// \brief Resize the buffer that holds the data.
     ///                The new size of the current data is based on the


reply via email to

[Prev in Thread] Current Thread [Next in Thread]