[PATCH 4/5] Attempt to free plot data entries regardless of printer state

Lubomir I. Ivanov neolit123 at gmail.com
Sun Dec 16 14:26:37 PST 2012


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

profile.c:plot() does take care of freeing the previously allocated array
of "struct plot_data" entries, but only if the "printer" flag in
gc (struct graphics_context) is set.

Attempt to free these entries regardless, as they may cause a decent memory
leak chunk after a prolonged session. Brief tests show no negative effects
after this change.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 profile.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/profile.c b/profile.c
index 984c5e2..891a255 100644
--- a/profile.c
+++ b/profile.c
@@ -1877,11 +1877,9 @@ void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale)
 
 	plot_depth_scale(gc, pi);
 
-	if (gc->printer) {
-		free(pi->entry);
-		pi->entry = NULL;
-		pi->nr = 0;
-	}
+	free(pi->entry);
+	pi->entry = NULL;
+	pi->nr = 0;
 }
 
 static void plot_string(struct plot_data *entry, char *buf, size_t bufsize,
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list