From bedf374e8fd18408c17d486de9a7e6ec2a1c5ecc Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Tue, 28 Feb 2012 12:09:32 -0500
Subject: [PATCH] * #8968: use auto_ptr for dtmfKey

---
 daemon/src/managerimpl.cpp | 8 +++-----
 daemon/src/managerimpl.h   | 4 ++--
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index c660a68700..96d6aa5e99 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -123,7 +123,7 @@ void ManagerImpl::init(std::string config_file)
         ost::MutexLock lock(audioLayerMutex_);
         if (audiodriver_) {
             telephoneTone_ = new TelephoneTone(preferences.getZoneToneChoice(), audiodriver_->getSampleRate());
-            dtmfKey_ = new DTMF(8000);
+            dtmfKey_.reset(new DTMF(8000));
         }
     }
 
@@ -142,7 +142,6 @@ void ManagerImpl::terminate()
     unloadAccountMap();
 
     delete SIPVoIPLink::instance();
-    delete dtmfKey_;
     delete telephoneTone_;
     telephoneTone_ = NULL;
 
@@ -1308,7 +1307,7 @@ void ManagerImpl::playDtmf(char code)
     //                = number of seconds * SAMPLING_RATE by SECONDS
 
     // fast return, no sound, so no dtmf
-    if (audiodriver_ == NULL || dtmfKey_ == NULL) {
+    if (audiodriver_ == NULL || dtmfKey_.get() == 0) {
         DEBUG("Manager: playDtmf: Error no audio layer...");
         return;
     }
@@ -2314,8 +2313,7 @@ void ManagerImpl::audioSamplingRateChanged(int samplerate)
     delete telephoneTone_;
     telephoneTone_ = new TelephoneTone(preferences.getZoneToneChoice(), sampleRate);
 
-    delete dtmfKey_;
-    dtmfKey_ = new DTMF(sampleRate);
+    dtmfKey_.reset(new DTMF(sampleRate));
 
     if (wasActive)
         audiodriver_->startStream();
diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h
index a9ebb8f45a..b1ff382644 100644
--- a/daemon/src/managerimpl.h
+++ b/daemon/src/managerimpl.h
@@ -40,6 +40,7 @@
 #include <set>
 #include <map>
 #include <cc++/thread.h>
+#include <memory>
 #include "dbus/dbusmanager.h"
 
 #include "config/config.h"
@@ -940,8 +941,7 @@ class ManagerImpl {
         AudioLayer* audiodriver_;
 
         // Main thread
-
-        DTMF* dtmfKey_;
+        std::auto_ptr<DTMF> dtmfKey_;
 
         /////////////////////
         // Protected by Mutex
-- 
GitLab