fix memory leak on sound shutdown
authorsapier <Sapier at GMX dot net>
Sun, 7 Apr 2013 19:17:26 +0000 (21:17 +0200)
committerkwolekr <kwolekr@minetest.net>
Mon, 8 Apr 2013 03:43:34 +0000 (23:43 -0400)
src/sound_openal.cpp

index cc5261eaeb82619ee2eb4ab3051466ab1c3500d5..0cfbc279829a95978c94979d3339eb4be67332d8 100644 (file)
@@ -271,6 +271,16 @@ public:
                m_context = NULL;
                alcCloseDevice(m_device);
                m_device = NULL;
+
+               for (std::map<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.begin();
+                               i != m_buffers.end(); i++) {
+                       for (std::vector<SoundBuffer*>::iterator iter = (*i).second.begin();
+                                       iter != (*i).second.end(); iter++) {
+                               delete *iter;
+                       }
+                       (*i).second.clear();
+               }
+               m_buffers.clear();
                infostream<<"Audio: Deinitialized."<<std::endl;
        }