aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2011-05-10 16:45:24 +0300
committerArjan van de Ven <arjan@linux.intel.com>2011-05-11 00:04:39 -0400
commitcce4bc562b6fedce48fe03ff681da84a629c30a1 (patch)
tree90df79f3f649a16e5bd1e4f9dcd5c919de2160cb
parente74ee7a1de23089264c78c2227af9407d74456e3 (diff)
downloadpowertop-cce4bc562b6fedce48fe03ff681da84a629c30a1.tar.gz
process/timer: Rework clear_timers() to free allocated memory
Rework clear_timers() to free allocated for all_timers memory and make it extern. Thus we can call it from do_process instead of explicit iterating through all_timers. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
-rw-r--r--process/timer.cpp11
-rw-r--r--process/timer.h3
2 files changed, 10 insertions, 4 deletions
diff --git a/process/timer.cpp b/process/timer.cpp
index 9cd9cc2..c888be4 100644
--- a/process/timer.cpp
+++ b/process/timer.cpp
@@ -94,7 +94,7 @@ const char * timer::description(void)
class timer * find_create_timer(uint64_t func)
{
class timer * timer;
- if (all_timers[func])
+ if (all_timers.find(func) != all_timers.end())
return all_timers[func];
timer = new class timer(func);
@@ -105,5 +105,10 @@ class timer * find_create_timer(uint64_t func)
void clear_timers(void)
{
- all_timers.erase(all_timers.begin(), all_timers.end());
-} \ No newline at end of file
+ std::map<unsigned long, class timer *>::iterator it = all_timers.begin();
+ while (it != all_timers.end()) {
+ delete it->second;
+ all_timers.erase(it);
+ it = all_timers.begin();
+ }
+}
diff --git a/process/timer.h b/process/timer.h
index 0c9ab5b..5ff3efd 100644
--- a/process/timer.h
+++ b/process/timer.h
@@ -55,5 +55,6 @@ public:
extern void all_timers_to_all_power(void);
extern class timer * find_create_timer(uint64_t func);
+extern void clear_timers(void);
-#endif \ No newline at end of file
+#endif