PluginInfo::type added to copy constructor. But why is the copy constructor defined...
[ardour.git] / libs / pbd / pool.cc
index be8032b7b63520d31d2a431694b2298f5a19634b..ffaea3c1a2529b0ade99f9f9e0c6d879b01fb583 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <iostream>
 #include <vector>
+#include <cstdlib>
 
 #include <pbd/pool.h>
 #include <pbd/error.h>
@@ -83,37 +84,37 @@ Pool::release (void *ptr)
 
 MultiAllocSingleReleasePool::MultiAllocSingleReleasePool (string n, unsigned long isize, unsigned long nitems) 
        : Pool (n, isize, nitems),
-        m_lock(0)
+         m_lock(0)
 {
 }
 
 MultiAllocSingleReleasePool::~MultiAllocSingleReleasePool ()
 {
-    if(m_lock) delete m_lock;
+       if (m_lock) delete m_lock;
 }
 
 SingleAllocMultiReleasePool::SingleAllocMultiReleasePool (string n, unsigned long isize, unsigned long nitems) 
        : Pool (n, isize, nitems),
-    m_lock(0)
+         m_lock(0)
 {
 }
 
 SingleAllocMultiReleasePool::~SingleAllocMultiReleasePool ()
 {
-    if(m_lock) delete m_lock;
+       if (m_lock) delete m_lock;
 }
 
 void*
 MultiAllocSingleReleasePool::alloc ()
 {
        void *ptr;
-    if(!m_lock) {
-        m_lock = new Glib::Mutex();
-        // umm, I'm not sure that this doesn't also allocate memory.
-        if(!m_lock) error << "cannot create Glib::Mutex in pool.cc" << endmsg;
-    }
+
+       if (!m_lock && (m_lock = new Glib::Mutex()) == 0) {
+               fatal << "cannot create Glib::Mutex in pool.cc" << endmsg;
+               /*NOTREACHED*/
+       }
     
-    Glib::Mutex::Lock guard(*m_lock);
+       Glib::Mutex::Lock guard(*m_lock);
        ptr = Pool::alloc ();
        return ptr;
 }
@@ -133,12 +134,12 @@ SingleAllocMultiReleasePool::alloc ()
 void
 SingleAllocMultiReleasePool::release (void* ptr)
 {
-    if(!m_lock) {
-        m_lock = new Glib::Mutex();
-        // umm, I'm not sure that this doesn't also allocate memory.
-        if(!m_lock) error << "cannot create Glib::Mutex in pool.cc" << endmsg;
-    }
-    Glib::Mutex::Lock guard(*m_lock);
+       if (!m_lock && (m_lock = new Glib::Mutex()) == 0) {
+               fatal << "cannot create Glib::Mutex in pool.cc" << endmsg;
+               /*NOTREACHED*/
+       }
+
+       Glib::Mutex::Lock guard(*m_lock);
        Pool::release (ptr);
 }