This plugs a leak detected by valgrind.

Signed-off-by: Anton Lundin <[email protected]>
---
 main.cpp            |  1 +
 subsurfacestartup.c | 17 +++++++++++++++++
 subsurfacestartup.h |  1 +
 3 files changed, 19 insertions(+)

diff --git a/main.cpp b/main.cpp
index fe44cca..3989cc9 100644
--- a/main.cpp
+++ b/main.cpp
@@ -68,5 +68,6 @@ int main(int argc, char **argv)
        exit_ui();
        parse_xml_exit();
        subsurface_console_exit();
+       free_prefs();
        return 0;
 }
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 8847ab3..618e942 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -219,3 +219,20 @@ void setup_system_prefs(void)
 
        default_prefs.units = IMPERIAL_units;
 }
+
+/*
+ * Free strduped prefs before exit.
+ *
+ * These are not real leaks but they plug the holes found by eg.
+ * valgrind so you can find the real leaks.
+ */
+void free_prefs(void)
+{
+       free((void*)prefs.default_filename);
+       free((void*)prefs.default_cylinder);
+       free((void*)prefs.divelist_font);
+       free(prefs.proxy_host);
+       free(prefs.proxy_user);
+       free(prefs.proxy_pass);
+       free(prefs.userid);
+}
diff --git a/subsurfacestartup.h b/subsurfacestartup.h
index 8eaaaa0..44db42e 100644
--- a/subsurfacestartup.h
+++ b/subsurfacestartup.h
@@ -15,6 +15,7 @@ extern bool imported;
 
 void setup_system_prefs(void);
 void parse_argument(const char *arg);
+void free_prefs(void);
 
 #ifdef __cplusplus
 }
-- 
2.1.0

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to