From patchwork Wed Sep 7 09:44:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 3958 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DBFC523EFD for ; Wed, 7 Sep 2011 09:44:16 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id C4E24A180A6 for ; Wed, 7 Sep 2011 09:44:16 +0000 (UTC) Received: by fxd18 with SMTP id 18so548714fxd.11 for ; Wed, 07 Sep 2011 02:44:16 -0700 (PDT) Received: by 10.223.76.201 with SMTP id d9mr1806626fak.119.1315388656554; Wed, 07 Sep 2011 02:44:16 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs133066lab; Wed, 7 Sep 2011 02:44:16 -0700 (PDT) Received: by 10.216.88.145 with SMTP id a17mr876808wef.107.1315388655836; Wed, 07 Sep 2011 02:44:15 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id e47si3081061wed.63.2011.09.07.02.44.15 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Sep 2011 02:44:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1R1Eg3-0002CC-8T for ; Wed, 07 Sep 2011 09:44:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 34EE1E01C7 for ; Wed, 7 Sep 2011 09:44:15 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 129 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 129: Free memory alloacated by scenes and benchmarks on program exit. Message-Id: <20110907094415.13575.66028.launchpad@ackee.canonical.com> Date: Wed, 07 Sep 2011 09:44:15 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13861"; Instance="initZopeless config overlay" X-Launchpad-Hash: 0ce97d68aaa2be9cdabe5b97a7eb2e41f652cd6f ------------------------------------------------------------ revno: 129 committer: Alexandros Frantzis branch nick: trunk timestamp: Wed 2011-09-07 12:40:57 +0300 message: Free memory alloacated by scenes and benchmarks on program exit. Although this is not really necessary, it removes some annoying valgrind leak reports and therefore makes it easier to discover *real* memory leaks. modified: src/main.cpp src/util.h --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/main.cpp' --- src/main.cpp 2011-08-18 15:03:40 +0000 +++ src/main.cpp 2011-09-07 09:40:57 +0000 @@ -26,6 +26,7 @@ #include "benchmark.h" #include "options.h" #include "log.h" +#include "util.h" #include @@ -82,6 +83,28 @@ } } +void +add_and_register_scenes(vector& scenes, Canvas& canvas) +{ + scenes.push_back(new SceneDefaultOptions(canvas)); + scenes.push_back(new SceneBuild(canvas)); + scenes.push_back(new SceneTexture(canvas)); + scenes.push_back(new SceneShading(canvas)); + scenes.push_back(new SceneConditionals(canvas)); + scenes.push_back(new SceneFunction(canvas)); + scenes.push_back(new SceneLoop(canvas)); + scenes.push_back(new SceneBump(canvas)); + scenes.push_back(new SceneEffect2D(canvas)); + scenes.push_back(new ScenePulsar(canvas)); + + for (vector::const_iterator iter = scenes.begin(); + iter != scenes.end(); + iter++) + { + Benchmark::register_scene(**iter); + } +} + static void list_scenes() { @@ -220,17 +243,10 @@ CanvasX11EGL canvas(Options::size.first, Options::size.second); #endif - // Register the scenes, so they can be looked-up by name - Benchmark::register_scene(*new SceneDefaultOptions(canvas)); - Benchmark::register_scene(*new SceneBuild(canvas)); - Benchmark::register_scene(*new SceneTexture(canvas)); - Benchmark::register_scene(*new SceneShading(canvas)); - Benchmark::register_scene(*new SceneConditionals(canvas)); - Benchmark::register_scene(*new SceneFunction(canvas)); - Benchmark::register_scene(*new SceneLoop(canvas)); - Benchmark::register_scene(*new SceneBump(canvas)); - Benchmark::register_scene(*new SceneEffect2D(canvas)); - Benchmark::register_scene(*new ScenePulsar(canvas)); + vector scenes; + + // Register the scenes, so they can be looked up by name + add_and_register_scenes(scenes, canvas); if (Options::list_scenes) { list_scenes(); @@ -263,5 +279,8 @@ else do_benchmark(canvas, benchmarks); + Util::dispose_pointer_vector(benchmarks); + Util::dispose_pointer_vector(scenes); + return 0; } === modified file 'src/util.h' --- src/util.h 2011-08-10 17:58:47 +0000 +++ src/util.h 2011-09-07 09:40:57 +0000 @@ -35,6 +35,18 @@ struct Util { static void split(const std::string &s, char delim, std::vector &elems); static std::istream *get_resource(const std::string &path); + template static void dispose_pointer_vector(std::vector &vec) + { + for (typename std::vector::const_iterator iter = vec.begin(); + iter != vec.end(); + iter++) + { + delete *iter; + } + + vec.clear(); + } + #ifdef ANDROID static void android_set_asset_manager(AAssetManager *asset_manager); private: