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++)
|
for (int j = 0; j < 3; j++)
|
||||||
buffList[j] = 0;
|
buffList[j] = NULL;
|
||||||
|
|
||||||
if ((status = fBuffers->GetBufferList(3, buffList)) == B_OK)
|
if ((status = fBuffers->GetBufferList(3, buffList)) == B_OK)
|
||||||
for (int j = 0; j < 3; j++)
|
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)
|
if (name == NULL || strlen(name) == 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
BBuffer** buffers;
|
BBuffer* buffers[fBufferCount];
|
||||||
int32 count;
|
status_t status = GetBufferList(fBufferCount, buffers);
|
||||||
|
|
||||||
count = fBufferCount;
|
|
||||||
buffers = new BBuffer * [count];
|
|
||||||
|
|
||||||
status_t status = GetBufferList(count, buffers);
|
|
||||||
if (status != B_OK)
|
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()));
|
status = message->AddInt32(name, int32(buffers[i]->ID()));
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
goto end;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
return B_OK;
|
||||||
delete [] buffers;
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user