changeset 1151:278bbfd85a02

Bound at-exit memory deallocation
author corvid <corvid@lavabit.com>
date Sun, 31 May 2009 17:22:07 -0400
parents 9b75aac0a62f
children 523f2873b999
files src/IO/http.c src/dillo.cc src/history.c src/history.h src/prefs.c src/prefs.h
diffstat 6 files changed, 45 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/IO/http.c	Sun May 31 16:37:39 2009 -0400
+++ b/src/IO/http.c	Sun May 31 17:22:07 2009 -0400
@@ -548,4 +548,5 @@
    a_Klist_free(&ValidSocks);
    a_Url_free(HTTP_Proxy);
    dFree(HTTP_Proxy_Auth_base64);
+   dFree(HTTP_Language_hdr);
 }
--- a/src/dillo.cc	Sun May 31 16:37:39 2009 -0400
+++ b/src/dillo.cc	Sun May 31 17:22:07 2009 -0400
@@ -38,6 +38,7 @@
 #include "bw.h"
 #include "misc.h"
 #include "nav.h"
+#include "history.h"
 
 #include "dns.h"
 #include "web.hh"
@@ -349,5 +350,23 @@
       }
    }
 
-   return fltk::run();
+   fltk::run();
+
+   /*
+    * Memory deallocating routines
+    * (This can be left to the OS, but we'll do it, with a view to test
+    *  and fix our memory management)
+    */
+   a_Cookies_freeall();
+   a_Cache_freeall();
+   a_Dicache_freeall();
+   a_Http_freeall();
+   a_Dns_freeall();
+   a_History_freeall();
+   a_Prefs_freeall();
+   /* TODO: auth, css */
+
+   //a_Dpi_bye_dpid();
+   MSG("Dillo: normal exit!\n");
+   return 0;
 }
--- a/src/history.c	Sun May 31 16:37:39 2009 -0400
+++ b/src/history.c	Sun May 31 17:22:07 2009 -0400
@@ -149,7 +149,7 @@
 /*
  * Free all the memory used by this module
  */
-void a_History_free()
+void a_History_freeall()
 {
    int i;
 
--- a/src/history.h	Sun May 31 16:37:39 2009 -0400
+++ b/src/history.h	Sun May 31 17:22:07 2009 -0400
@@ -14,7 +14,7 @@
 DilloUrl *a_History_get_url(int idx);
 const char *a_History_get_title(int idx, int force);
 const char *a_History_get_title_by_url(const DilloUrl *url, int force);
-void a_History_free(void);
+void a_History_freeall(void);
 
 
 #ifdef __cplusplus
--- a/src/prefs.c	Sun May 31 16:37:39 2009 -0400
+++ b/src/prefs.c	Sun May 31 17:22:07 2009 -0400
@@ -79,3 +79,24 @@
    prefs.w3c_plus_heuristics = TRUE;
 }
 
+/*
+ *  memory-deallocation
+ *  (Call this one at exit time)
+ */
+void a_Prefs_freeall(void)
+{
+   dFree(prefs.font_cursive);
+   dFree(prefs.font_fantasy);
+   dFree(prefs.font_monospace);
+   dFree(prefs.font_sans_serif);
+   dFree(prefs.font_serif);
+   a_Url_free(prefs.home);
+   dFree(prefs.http_language);
+   a_Url_free(prefs.http_proxy);
+   dFree(prefs.http_proxyuser);
+   dFree(prefs.http_referer);
+   dFree(prefs.no_proxy);
+   dFree(prefs.save_dir);
+   dFree(prefs.search_url);
+   a_Url_free(prefs.start_page);
+}
--- a/src/prefs.h	Sun May 31 16:37:39 2009 -0400
+++ b/src/prefs.h	Sun May 31 17:22:07 2009 -0400
@@ -97,6 +97,7 @@
 extern DilloPrefs prefs;
 
 void a_Prefs_init(void);
+void a_Prefs_freeall(void);
 
 #ifdef __cplusplus
 }