[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/sound_handler.h
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler.h |
Date: |
Wed, 26 Sep 2007 09:28:27 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/09/26 09:28:27
Modified files:
. : ChangeLog
backend : sound_handler.h
Log message:
* backend/sound_handler.h: add assign() and constructor taking
a memory buffer to the Buffer class.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4416&r2=1.4417
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.h?cvsroot=gnash&r1=1.29&r2=1.30
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4416
retrieving revision 1.4417
diff -u -b -r1.4416 -r1.4417
--- ChangeLog 26 Sep 2007 08:49:46 -0000 1.4416
+++ ChangeLog 26 Sep 2007 09:28:26 -0000 1.4417
@@ -1,5 +1,10 @@
2007-09-26 Sandro Santilli <address@hidden>
+ * backend/sound_handler.h: add assign() and constructor taking
+ a memory buffer to the Buffer class.
+
+2007-09-26 Sandro Santilli <address@hidden>
+
* backend/sound_handler.h (Buffer::reserve): don't try to copy
from the NULL pointer.
Index: backend/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- backend/sound_handler.h 26 Sep 2007 08:49:47 -0000 1.29
+++ backend/sound_handler.h 26 Sep 2007 09:28:27 -0000 1.30
@@ -18,7 +18,7 @@
//
//
-/* $Id: sound_handler.h,v 1.29 2007/09/26 08:49:47 strk Exp $ */
+/* $Id: sound_handler.h,v 1.30 2007/09/26 09:28:27 strk Exp $ */
/// \page sound_handler_intro Sound handler introduction
///
@@ -56,11 +56,26 @@
_size(0)
{}
+ /// Create a Buffer with the given initial content
+ //
+ /// @param newData data to assign to this buffer.
+ /// Allocated with new[]. Ownership transferred.
+ ///
+ /// @param size number of bytes in the new data
+ ///
+ Buffer(uint8_t* newData, size_t size)
+ :
+ _capacity(size),
+ _data(newData),
+ _size(size)
+ {}
+
/// Append data to this buffer
//
/// @param newData data to append to this buffer.
+ /// Allocated with new[]. Ownership transferred.
///
- /// @param size number of elements
+ /// @param size number of bytes in the new data
///
void append(uint8_t* newData, size_t size)
{
@@ -80,6 +95,34 @@
delete [] newData;
}
+ /// Assign data to this buffer
+ //
+ /// @param newData data to assign to this buffer.
+ /// Allocated with new[]. Ownership transferred.
+ ///
+ /// @param size number of bytes in the new data
+ ///
+ void assign(uint8_t* newData, size_t size)
+ {
+ if ( ! _capacity )
+ {
+ _data = newData;
+ _size = size;
+ _capacity = _size;
+ return;
+ }
+
+ _size=0; // so reserve won't memcpy...
+ reserve(size);
+
+ assert(_capacity >= size);
+
+ memcpy(_data, newData, size);
+ _size = size;
+
+ delete [] newData;
+ }
+
const uint8_t* data() const
{
return _data;
@@ -120,7 +163,7 @@
_data = new uint8_t[_capacity];
if ( tmp )
{
- memcpy(_data, tmp, _size);
+ if ( _size ) memcpy(_data, tmp, _size);
delete [] tmp;
}
}