From patchwork Wed Feb 20 14:37:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 595 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D9F1D60100 for ; Wed, 20 Feb 2019 15:38:48 +0100 (CET) X-Halon-ID: 39bae34c-351d-11e9-b530-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 39bae34c-351d-11e9-b530-005056917a89; Wed, 20 Feb 2019 15:38:45 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Feb 2019 15:37:33 +0100 Message-Id: <20190220143736.529-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220143736.529-1-niklas.soderlund@ragnatech.se> References: <20190220143736.529-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] cam: free allocated buffers when done capturing X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2019 14:38:49 -0000 The allocated buffers needs to be freed once the application is done with them. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- 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 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; }