Rename delete_all_work() to clear_work() to keep names unified (as we do for
clear_{timers,interrupts,etc}). Rework clear_work() to free allocated for
all_work memory.
Signed-off-by: Sergey Senozhatsky <[email protected]>
---
diff --git a/process/work.cpp b/process/work.cpp
index ed84062..90cc3e1 100644
--- a/process/work.cpp
+++ b/process/work.cpp
@@ -81,10 +81,14 @@ void all_work_to_all_power(void)
}
-void delete_all_work(void)
+void clear_work(void)
{
- /* TODO: does this call the destructors/delete ? */
- all_work.erase(all_work.begin(), all_work.end());
+ std::map<unsigned long, class work *>::iterator it = all_work.begin();
+ while (it != all_work.end()) {
+ delete it->second;
+ all_work.erase(it);
+ it = all_work.begin();
+ }
}
@@ -100,12 +104,11 @@ const char * work::description(void)
class work * find_create_work(uint64_t func)
{
class work * work;
- if (all_work[func])
+ if (all_work.find(func) != all_work.end())
return all_work[func];
work = new class work(func);
all_work[func] = work;
return work;
-
}
diff --git a/process/work.h b/process/work.h
index c69cc95..47a469f 100644
--- a/process/work.h
+++ b/process/work.h
@@ -50,6 +50,6 @@ public:
extern void all_work_to_all_power(void);
extern class work * find_create_work(uint64_t func);
-extern void delete_all_work(void);
+extern void clear_work(void);
-#endif
\ No newline at end of file
+#endif
_______________________________________________
Discuss mailing list
[email protected]
http://lists.lesswatts.org/listinfo/discuss