diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 22:36:02 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 22:36:02 +0000 |
commit | 4abb93959ea4d1ffafa6681ee4c543f9a5d5691b (patch) | |
tree | 47f0b882de7a5082402d3a438c233cee3a38a5aa /base/mime_util_linux.cc | |
parent | cec1217e4e67794cf7c70c070dcc69135e38446a (diff) | |
download | chromium_src-4abb93959ea4d1ffafa6681ee4c543f9a5d5691b.zip chromium_src-4abb93959ea4d1ffafa6681ee4c543f9a5d5691b.tar.gz chromium_src-4abb93959ea4d1ffafa6681ee4c543f9a5d5691b.tar.bz2 |
Fix memory leaks in mime_util functions.
Review URL: http://codereview.chromium.org/115541
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mime_util_linux.cc')
-rw-r--r-- | base/mime_util_linux.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/base/mime_util_linux.cc b/base/mime_util_linux.cc index 1866545..36d9029 100644 --- a/base/mime_util_linux.cc +++ b/base/mime_util_linux.cc @@ -53,6 +53,7 @@ class MimeUtilConstants { icon_themes(NULL), last_check_time(0) { } + ~MimeUtilConstants(); friend struct DefaultSingletonTraits<MimeUtilConstants>; DISALLOW_COPY_AND_ASSIGN(MimeUtilConstants); }; @@ -429,19 +430,18 @@ void EnsureUpdated() { gettimeofday(&t, NULL); time_t now = t.tv_sec; MimeUtilConstants* constants = Singleton<MimeUtilConstants>::get(); - time_t last_check_time = constants->last_check_time; - if (last_check_time == 0) { + if (constants->last_check_time == 0) { constants->icon_dirs = new std::map<FilePath, int>; constants->icon_themes = new std::map<std::string, IconTheme*>; constants->icon_formats = new std::vector<std::string>; EnableSvgIcon(true); InitIconDir(); - last_check_time = now; + constants->last_check_time = now; } else { // TODO(thestig): something changed. start over. Upstream fix to Google // Gadgets for Linux. - if (now > last_check_time + constants->kUpdateInterval) { + if (now > constants->last_check_time + constants->kUpdateInterval) { } } } @@ -473,6 +473,8 @@ void InitDefaultThemes() { char* env = getenv("GGL_ICON_THEME"); if (env) default_themes[0] = IconTheme::LoadTheme(env); + else + default_themes[0] = NULL; env = getenv("KDE_FULL_SESSION"); if (env) { @@ -512,6 +514,14 @@ FilePath LookupIconInDefaultTheme(const std::string& icon_name, int size) { return LookupFallbackIcon(icon_name); } +MimeUtilConstants::~MimeUtilConstants() { + delete icon_dirs; + delete icon_formats; + delete icon_themes; + for (size_t i = 0; i < kDefaultThemeNum; i++) + delete default_themes[i]; +} + } // namespace namespace mime_util { |