mirror of
https://github.com/esphome/esphome.git
synced 2026-10-15 18:52:51 +00:00
27 lines
603 B
C++
27 lines
603 B
C++
#include "encoder_buffer_impl.h"
|
|
|
|
namespace esphome::camera_encoder {
|
|
|
|
bool EncoderBufferImpl::set_buffer_size(size_t size) {
|
|
if (size > this->capacity_) {
|
|
RAMAllocator<uint8_t> allocator;
|
|
uint8_t *p = allocator.reallocate(this->data_, size);
|
|
if (p == nullptr)
|
|
return false;
|
|
|
|
this->data_ = p;
|
|
this->capacity_ = size;
|
|
}
|
|
this->size_ = size;
|
|
return true;
|
|
}
|
|
|
|
EncoderBufferImpl::~EncoderBufferImpl() {
|
|
if (this->data_ != nullptr) {
|
|
RAMAllocator<uint8_t> allocator;
|
|
allocator.deallocate(this->data_, this->capacity_);
|
|
}
|
|
}
|
|
|
|
} // namespace esphome::camera_encoder
|