diff options
author | Hirokazu Honda <hiroh@chromium.org> | 2021-03-24 16:07:56 +0900 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-03-25 00:45:27 +0200 |
commit | dca709c44aeb0d6532edf3000f701f5d988c5116 (patch) | |
tree | 3aaebe94dc4b0a45137480db221ae81249ba4aac /src/android/camera_device.cpp | |
parent | 17a6e78e000bef54af9057fe5e84bdafb2759db4 (diff) |
android: CameraDevice: Manage staticMetadata_ with std::unique_ptr
staticMetadata_ in CameraDevice is not necessary to be a raw
pointer. This reduces the manual new/delete code by changing the
type to std::unique_ptr.
Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android/camera_device.cpp')
-rw-r--r-- | src/android/camera_device.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index e75fd25f..8fdcb85a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -311,8 +311,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor() = default; CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera) : id_(id), running_(false), camera_(std::move(camera)), - staticMetadata_(nullptr), facing_(CAMERA_FACING_FRONT), - orientation_(0) + facing_(CAMERA_FACING_FRONT), orientation_(0) { camera_->requestCompleted.connect(this, &CameraDevice::requestComplete); @@ -341,9 +340,6 @@ CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera) CameraDevice::~CameraDevice() { - if (staticMetadata_) - delete staticMetadata_; - for (auto &it : requestTemplates_) delete it.second; } @@ -732,11 +728,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() uint32_t numEntries; uint32_t byteSize; std::tie(numEntries, byteSize) = calculateStaticMetadataSize(); - staticMetadata_ = new CameraMetadata(numEntries, byteSize); + staticMetadata_ = std::make_unique<CameraMetadata>(numEntries, byteSize); if (!staticMetadata_->isValid()) { LOG(HAL, Error) << "Failed to allocate static metadata"; - delete staticMetadata_; - staticMetadata_ = nullptr; + staticMetadata_.reset(); return nullptr; } @@ -1356,8 +1351,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() if (!staticMetadata_->isValid()) { LOG(HAL, Error) << "Failed to construct static metadata"; - delete staticMetadata_; - staticMetadata_ = nullptr; + staticMetadata_.reset(); return nullptr; } |