Skip to content

Commit

Permalink
BBuffer: initialize variables and cleanup
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Numerio committed Jul 11, 2015
1 parent 8c19f07 commit 3317921
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/kits/media/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 4 additions & 3 deletions src/kits/media/SharedBufferList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");


Expand Down Expand Up @@ -419,6 +419,7 @@ SharedBufferList::_Init()
for (int32 i = 0; i < kMaxBuffers; i++) {
fInfos[i].id = -1;
}
fCount = 0;

return B_OK;
}
Expand Down

0 comments on commit 3317921

Please sign in to comment.