[libcamera-devel] [PATCH 1/4] cam: free allocated buffers when done capturing
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Feb 22 01:34:24 CET 2019
Hi Niklas,
Thank you for the patch.
On Wed, Feb 20, 2019 at 03:37:33PM +0100, Niklas Söderlund wrote:
> The allocated buffers needs to be freed once the application is done
> with them.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Does this fix valgrind warnings ?
> ---
> src/cam/main.cpp | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index 9b67ab75a6a1663e..b034eb25429abeb3 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -163,7 +163,8 @@ static int capture()
> Request *request = camera->createRequest();
> if (!request) {
> std::cerr << "Can't create request" << std::endl;
> - return -ENOMEM;
> + ret = -ENOMEM;
> + goto out;
> }
>
> std::map<Stream *, Buffer *> map;
> @@ -171,13 +172,13 @@ static int capture()
> ret = request->setBuffers(map);
> if (ret < 0) {
> std::cerr << "Can't set buffers for request" << std::endl;
> - return ret;
> + goto out;
> }
>
> ret = camera->queueRequest(request);
> if (ret < 0) {
> std::cerr << "Can't queue request" << std::endl;
> - return ret;
> + goto out;
> }
> }
>
> @@ -187,6 +188,9 @@ static int capture()
> ret = loop->exec();
>
> camera->stop();
> +out:
> + camera->freeBuffers();
> +
> return ret;
> }
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list