From 932eebe0ddbc611ccf72cbebebbde656ae2d08ec Mon Sep 17 00:00:00 2001
From: simonb <simonb>
Date: Sat, 22 Apr 2006 15:37:04 +0000
Subject: couple of memory fixes from valgrind

---
 ChangeLog          | 2 ++
 src/Keys.cc        | 3 +--
 src/MenuCreator.cc | 4 ++--
 src/Screen.cc      | 5 ++++-
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e6c34d7..2abe162 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 (Format: Year/Month/Day)
 Changes for 0.9.16:
 *06/04/22:
+   * Couple of memory-based fixes from valgrind (Simon)
+     Keys.cc Screen.cc MenuCreator.cc
    * Applied #1467926 and #1458069, minor other changes (Mathias)
      docs/asciidoc/fluxbox.txt
    * static CommandParser could be used after destruction (Simon)
diff --git a/src/Keys.cc b/src/Keys.cc
index c4099f6..78ad912 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -117,8 +117,8 @@ void Keys::deleteTree() {
             delete *it;
         map_it->second->clear();
         delete map_it->second;
-        m_map.erase(map_it->first);
     }
+    m_map.clear();
 }
 
 /**
@@ -343,7 +343,6 @@ bool Keys::doAction(XKeyEvent &ke) {
  returns true on success else false
 */
 bool Keys::reconfigure(const char *filename) {
-    deleteTree();
     return load(filename);
 }
 
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index 9d2b4fa..4a2cc0e 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -458,7 +458,7 @@ FbTk::Menu *MenuCreator::createMenuType(const std::string &type, int screen_num)
         menu->disableTitle(); // not titlebar
         if (screen->windowMenuFilename().empty() ||
             ! createWindowMenuFromFile(screen->windowMenuFilename(), *menu, true)) {
-            char default_menu[][11] = {
+            char *default_menu[] = {
                 "shade", 
                 "stick",
                 "maximize",
@@ -472,7 +472,7 @@ FbTk::Menu *MenuCreator::createMenuType(const std::string &type, int screen_num)
                 "close",
                 0
             };
-            for (unsigned int i=0; i < sizeof(default_menu); ++i)
+            for (unsigned int i=0; default_menu[i]; ++i)
                 createWindowMenuItem(default_menu[i], "", *menu);
         }
         menu->reconfigure(); // update graphics
diff --git a/src/Screen.cc b/src/Screen.cc
index 4625b80..d19d16f 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -345,8 +345,11 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
     XSetErrorHandler((XErrorHandler) old);
 
     managed = running;
-    if (! managed)
+    if (! managed) {
+        delete m_placement_strategy; m_placement_strategy = 0;
+        delete m_focus_control; m_focus_control = 0;
         return;
+    }
 
     // TODO fluxgen: check if this is the right place
     m_head_areas = new HeadArea[numHeads() ? numHeads() : 1];
-- 
cgit v0.11.2