diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 15:47:39 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 15:47:39 +0000 |
commit | 173cb8a00462e07619c3de56e62dcbba56389ccc (patch) | |
tree | cd0b4413a470b3321e9789ab378d74c73d214e43 /base | |
parent | 9b7f232c238a4d4b09015ebb7b54a375a972d434 (diff) | |
download | chromium_src-173cb8a00462e07619c3de56e62dcbba56389ccc.zip chromium_src-173cb8a00462e07619c3de56e62dcbba56389ccc.tar.gz chromium_src-173cb8a00462e07619c3de56e62dcbba56389ccc.tar.bz2 |
For some reason, when I changed PathData to be a singleton (r722) Purify started noticing the leak that had existed in this data structure all along. Now we clean up the heap objects correctly.
BUG=1334485
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/path_service.cc | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/base/path_service.cc b/base/path_service.cc index f66069a..a3cb1a9 100644 --- a/base/path_service.cc +++ b/base/path_service.cc @@ -67,6 +67,7 @@ struct Provider { int key_start; int key_end; #endif + bool is_static; }; static Provider base_provider = { @@ -74,8 +75,9 @@ static Provider base_provider = { NULL, #ifndef NDEBUG base::PATH_START, - base::PATH_END + base::PATH_END, #endif + true }; #ifdef OS_WIN @@ -84,20 +86,22 @@ static Provider base_provider_win = { &base_provider, #ifndef NDEBUG base::PATH_WIN_START, - base::PATH_WIN_END + base::PATH_WIN_END, #endif + true }; #endif #ifdef OS_MACOSX - static Provider base_provider_mac = { +static Provider base_provider_mac = { base::PathProviderMac, &base_provider, #ifndef NDEBUG base::PATH_MAC_START, - base::PATH_MAC_END + base::PATH_MAC_END, #endif - }; + true +}; #endif #if defined(OS_LINUX) @@ -106,9 +110,10 @@ static Provider base_provider_linux = { &base_provider, #ifndef NDEBUG base::PATH_LINUX_START, - base::PATH_LINUX_END + base::PATH_LINUX_END, #endif - }; + true +}; #endif @@ -127,6 +132,16 @@ struct PathData { providers = &base_provider_linux; #endif } + + ~PathData() { + Provider* p = providers; + while (p) { + Provider* next = p->next; + if (!p->is_static) + delete p; + p = next; + } + } }; static PathData* GetPathData() { @@ -252,6 +267,7 @@ void PathService::RegisterProvider(ProviderFunc func, int key_start, #endif p = new Provider; + p->is_static = false; p->func = func; p->next = path_data->providers; #ifndef NDEBUG |