BBufferGroup::GetBufferList: avoid dynamic allocation
This commit is contained in:
@@ -316,9 +316,9 @@ VideoConsumer::CreateBuffers(const media_format& withFormat)
|
||||
}
|
||||
}
|
||||
|
||||
BBuffer** buffList = new BBuffer * [3];
|
||||
BBuffer* buffList[3];
|
||||
for (int j = 0; j < 3; j++)
|
||||
buffList[j] = 0;
|
||||
buffList[j] = NULL;
|
||||
|
||||
if ((status = fBuffers->GetBufferList(3, buffList)) == B_OK)
|
||||
for (int j = 0; j < 3; j++)
|
||||
|
||||
@@ -344,25 +344,18 @@ BBufferGroup::AddBuffersTo(BMessage* message, const char* name, bool needLock)
|
||||
if (name == NULL || strlen(name) == 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BBuffer** buffers;
|
||||
int32 count;
|
||||
|
||||
count = fBufferCount;
|
||||
buffers = new BBuffer * [count];
|
||||
|
||||
status_t status = GetBufferList(count, buffers);
|
||||
BBuffer* buffers[fBufferCount];
|
||||
status_t status = GetBufferList(fBufferCount, buffers);
|
||||
if (status != B_OK)
|
||||
goto end;
|
||||
return status;
|
||||
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
for (int32 i = 0; i < fBufferCount; i++) {
|
||||
status = message->AddInt32(name, int32(buffers[i]->ID()));
|
||||
if (status != B_OK)
|
||||
goto end;
|
||||
return status;
|
||||
}
|
||||
|
||||
end:
|
||||
delete [] buffers;
|
||||
return status;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user