Refactor legacy FrameBuffer to use EncodedImageBuffer::Realloc

Preparation for deleting VCMEncodedFrame::VerifyAndAllocate and
EncodedImage::Allocate.

Bug: webrtc:9378
Change-Id: If7c16061962bbd58c3e7d5720189854e00a3d7bf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/154570
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29339}
This commit is contained in:
Niels Möller
2019-09-30 10:18:16 +02:00
committed by Commit Bot
parent fbf75a7891
commit 2449d7aa78
4 changed files with 18 additions and 3 deletions

View File

@ -52,6 +52,11 @@ size_t EncodedImageBuffer::size() const {
}
void EncodedImageBuffer::Realloc(size_t size) {
// Calling realloc with size == 0 is equivalent to free, and returns nullptr.
// Which is confusing on systems where malloc(0) doesn't return a nullptr.
// More specifically, it breaks expectations of
// VCMSessionInfo::UpdateDataPointers.
RTC_DCHECK(size > 0);
buffer_ = static_cast<uint8_t*>(realloc(buffer_, size));
size_ = size;
}