libcamera: pipeline_handler: Return unique_ptr from generateConfiguration()
The PipelineHandler::generateConfiguration() function allocates a CameraConfiguration instance and returns it. The ownership of the instance is transferred to the caller. This is a perfect match for a std::unique_ptr<>, which the Camera::generateConfiguration() function already returns. Update PipelineHandler::generateConfiguration() to match it. This fixes a memory leak in one of the error return paths in the IPU3 pipeline handler. While at it, update the Camera::generateConfiguration() function documentation to drop the sentence that describes the ownership transfer, as that is implied by usage of std::unique_ptr<>. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -934,8 +934,7 @@ const std::set<Stream *> &Camera::streams() const
|
||||
* \context This function is \threadsafe.
|
||||
*
|
||||
* \return A CameraConfiguration if the requested roles can be satisfied, or a
|
||||
* null pointer otherwise. The ownership of the returned configuration is
|
||||
* passed to the caller.
|
||||
* null pointer otherwise.
|
||||
*/
|
||||
std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(const StreamRoles &roles)
|
||||
{
|
||||
@@ -949,7 +948,8 @@ std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(const StreamR
|
||||
if (roles.size() > streams().size())
|
||||
return nullptr;
|
||||
|
||||
CameraConfiguration *config = d->pipe_->generateConfiguration(this, roles);
|
||||
std::unique_ptr<CameraConfiguration> config =
|
||||
d->pipe_->generateConfiguration(this, roles);
|
||||
if (!config) {
|
||||
LOG(Camera, Debug)
|
||||
<< "Pipeline handler failed to generate configuration";
|
||||
@@ -966,7 +966,7 @@ std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(const StreamR
|
||||
|
||||
LOG(Camera, Debug) << msg.str();
|
||||
|
||||
return std::unique_ptr<CameraConfiguration>(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user