diff options
author | Reinhold Kainhofer <reinhold@kainhofer.com> | 2011-08-23 22:34:46 +0200 |
---|---|---|
committer | Reinhold Kainhofer <reinhold@kainhofer.com> | 2011-09-01 15:12:51 +0200 |
commit | 13da351ae100d476532c18241bbe91862fd287ed (patch) | |
tree | 6dd9838d528ed601bdf03ba69b2edb7bee97a256 /lily/skyline.cc | |
parent | 69622b49b7a5a9c992e36ef11ba60c1fdd3c34b6 (diff) |
Fix memleak: temporary skyline objects for systems were never deleted
Diffstat (limited to 'lily/skyline.cc')
-rw-r--r-- | lily/skyline.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lily/skyline.cc b/lily/skyline.cc index b6ea6b791b..8f62710b09 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -514,6 +514,7 @@ Skyline::distance (Skyline const &other, Real horizon_padding) const Skyline const *padded_this = this; Skyline const *padded_other = &other; + bool created_tmp_skylines = false; /* For systems, padding is not added at creation time. Padding is @@ -525,6 +526,7 @@ Skyline::distance (Skyline const &other, Real horizon_padding) const { padded_this = new Skyline (*padded_this, horizon_padding, X_AXIS); padded_other = new Skyline (*padded_other, horizon_padding, X_AXIS); + created_tmp_skylines = true; } list<Building>::const_iterator i = padded_this->buildings_.begin (); @@ -544,6 +546,13 @@ Skyline::distance (Skyline const &other, Real horizon_padding) const j++; start = end; } + + if (created_tmp_skylines) + { + delete padded_this; + delete padded_other; + } + return dist; } |