diff options
author | Josh Stone <jistone@redhat.com> | 2009-09-09 16:13:16 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-09-10 13:20:36 -0700 |
commit | c9efa5c99498ccb3d2f0f87bc373da7dfd1cc067 (patch) | |
tree | 2d8cf0995d76421ac3fbc08f4ee2c43e0fae639f /util.h | |
parent | 9aa8ffcea9980d24cc9c9f13d9dd51e46e6283bf (diff) | |
download | systemtap-steved-c9efa5c99498ccb3d2f0f87bc373da7dfd1cc067.tar.gz systemtap-steved-c9efa5c99498ccb3d2f0f87bc373da7dfd1cc067.tar.xz systemtap-steved-c9efa5c99498ccb3d2f0f87bc373da7dfd1cc067.zip |
Simplify deleting all map values
* util.h (delete_map): New templated map deleter.
* dwflpp.cxx (dwflpp::~dwflpp): Use it.
* tapsets.cxx (symbol_table::~symbol_table): Use it.
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -97,4 +97,16 @@ lex_cast_qstring(std::string const & in) return out; } + +// Delete all values from a map-like container and clear it +// (The template is permissive -- be good!) +template <typename T> +void delete_map(T& t) +{ + for (typename T::iterator i = t.begin(); i != t.end(); ++i) + delete i->second; + t.clear(); +} + + /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |