BBuffer: initialize variables and cleanup

* Restore the BSmallBuffer exception in constructor,
  it's not actually implemented or used but it should
  still be keep safe.
* Initialize some variables in BBuffer and BBufferGroup.
This commit is contained in:
Dario Casalinuovo
2015-07-11 15:40:17 +02:00
parent 8c19f07f3c
commit 331792160a
2 changed files with 12 additions and 7 deletions
+8 -4
View File
@@ -190,17 +190,21 @@ BBuffer::BBuffer(const buffer_clone_info& info)
fBufferList(NULL),
fArea(-1),
fData(NULL),
fSize(0)
fOffset(0),
fSize(0),
fFlags(0)
{
CALLED();
// Must be -1 if not registered
fMediaHeader.buffer = -1;
// Ensure that the media_header is clean
memset(&fMediaHeader, 0, sizeof(fMediaHeader));
// special case for BSmallBuffer
if (info.area == 0 && info.buffer == 0)
return;
// Must be -1 if registration fail
fMediaHeader.buffer = -1;
fBufferList = BPrivate::SharedBufferList::Get();
if (fBufferList == NULL) {
ERROR("BBuffer::BBuffer: BPrivate::SharedBufferList::Get() failed\n");
+4 -3
View File
@@ -25,9 +25,9 @@
#include <DataExchange.h>
static BPrivate::SharedBufferList* sList;
static area_id sArea;
static int32 sRefCount;
static BPrivate::SharedBufferList* sList = NULL;
static area_id sArea = -1;
static int32 sRefCount = 0;
static BLocker sLocker("shared buffer list");
@@ -419,6 +419,7 @@ SharedBufferList::_Init()
for (int32 i = 0; i < kMaxBuffers; i++) {
fInfos[i].id = -1;
}
fCount = 0;
return B_OK;
}