]> git.sesse.net Git - vlc/commitdiff
vlc_arrays: Adding a C++ helper to clean a container
authorHugo Beauzée-Luyssen <beauze.h@gmail.com>
Thu, 18 Nov 2010 12:10:37 +0000 (13:10 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Fri, 26 Nov 2010 18:47:47 +0000 (19:47 +0100)
Signed-off-by: Rémi Duraffort <ivoire@videolan.org>
include/vlc_arrays.h

index b8dbae473ccc7f428c7f79a3ed9ff90fb2eae9aa..c61c870b94dbd28e49d0bee39879d7a21bd0d54a 100644 (file)
@@ -617,4 +617,20 @@ vlc_dictionary_remove_value_for_key( const vlc_dictionary_t * p_dict, const char
     /* No key was found */
 }
 
+#ifdef __cplusplus
+// C++ helpers
+template <typename T>
+void vlc_delete_all( T &container )
+{
+    typename T::iterator it = container.begin();
+    while ( it != container.end() )
+    {
+        delete *it;
+        ++it;
+    }
+    container.clear();
+}
+
+#endif
+
 #endif