diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-07 06:55:35 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-07 06:55:35 +0000 |
commit | f7399bf929f401d4e1aa40f4f7a2265e2cdedc39 (patch) | |
tree | 2c704d6a78e5505ec9914bfd9d73cbebeeadf4ce /include/llvm/ADT/STLExtras.h | |
parent | 48aa5756a29a7b96850ac646d1edd806c9df4643 (diff) | |
download | external_llvm-f7399bf929f401d4e1aa40f4f7a2265e2cdedc39.zip external_llvm-f7399bf929f401d4e1aa40f4f7a2265e2cdedc39.tar.gz external_llvm-f7399bf929f401d4e1aa40f4f7a2265e2cdedc39.tar.bz2 |
Avoid leaking CompileUnits and DbgScopes from DwarfDebug. Leaks found by Valgrind!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/STLExtras.h')
-rw-r--r-- | include/llvm/ADT/STLExtras.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 32cf459..8dbf790 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -279,6 +279,28 @@ static inline void array_pod_sort(IteratorTy Start, IteratorTy End, qsort(&*Start, End-Start, sizeof(*Start), Compare); } +//===----------------------------------------------------------------------===// +// Extra additions to <algorithm> +//===----------------------------------------------------------------------===// + +/// For a container of pointers, deletes the pointers and then clears the +/// container. +template<typename Container> +void DeleteContainerPointers(Container &C) { + for (typename Container::iterator I = C.begin(), E = C.end(); I != E; ++I) + delete *I; + C.clear(); +} + +/// In a container of pairs (usually a map) whose second element is a pointer, +/// deletes the second elements and then clears the container. +template<typename Container> +void DeleteContainerSeconds(Container &C) { + for (typename Container::iterator I = C.begin(), E = C.end(); I != E; ++I) + delete I->second; + C.clear(); +} + } // End llvm namespace #endif |