[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/libbase Buffer.h
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash/libbase Buffer.h |
Date: |
Wed, 11 Jun 2008 14:22:00 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/06/11 14:22:00
Modified files:
libbase : Buffer.h
Log message:
more bug fixes
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Buffer.h?cvsroot=gnash&r1=1.2&r2=1.3
Patches:
Index: Buffer.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/Buffer.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Buffer.h 11 Jun 2008 14:02:54 -0000 1.2
+++ Buffer.h 11 Jun 2008 14:21:59 -0000 1.3
@@ -25,9 +25,9 @@
//#include "dsodefs.h" // for DSOEXPORT (not used)
-#include <cassert>
-#include <cstring> // for memcpy, should be changed to use std::copy
-#include <boost/scoped_array.hpp>
+#include <cassert> // for assert
+#include <boost/cstdint.hpp> // for boost::uint8_t
+#include <algorithm> // for std::copy
namespace gnash {
@@ -60,6 +60,12 @@
/// Return true if buffer is empty
bool empty() const { return _size==0; }
+ /// Return size of the buffer
+ size_t size() const { return _size; }
+
+ /// Return capacity of the buffer
+ size_t capacity() const { return _capacity; }
+
/// Get a pointer to start of data. May be NULL if size==0.
boost::uint8_t* data() { return _data; }
@@ -85,7 +91,7 @@
_data = new boost::uint8_t[_capacity];
if ( _size )
{
- std::copy(_data, tmp, _size);
+ std::copy(tmp, tmp+_size, _data);
delete [] tmp;
}
}
@@ -105,7 +111,7 @@
{
size_t curSize = _size;
resize(curSize+size);
- std::copy(_data+curSize, newData, size);
+ std::copy(newData, newData+size, _data+curSize);
assert(_size == curSize+size);
}