From 5738798c8cd4e4fe61425aa2ae4933b61a486a63 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Thu, 19 Apr 2012 18:11:30 -0400
Subject: [PATCH] iax: create iaxvoiplink on stack

---
 daemon/src/iax/iaxaccount.cpp | 19 ++++++-------------
 daemon/src/iax/iaxaccount.h   |  8 ++------
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/daemon/src/iax/iaxaccount.cpp b/daemon/src/iax/iaxaccount.cpp
index ae4affb029..5fbc1dc913 100644
--- a/daemon/src/iax/iaxaccount.cpp
+++ b/daemon/src/iax/iaxaccount.cpp
@@ -43,16 +43,9 @@
 #include "config/yamlemitter.h"
 
 IAXAccount::IAXAccount(const std::string& accountID)
-    : Account(accountID, "iax2"), password_(),
-    link_(new IAXVoIPLink(accountID))
+    : Account(accountID, "iax2"), password_(), link_(accountID)
 {}
 
-
-IAXAccount::~IAXAccount()
-{
-    delete link_;
-}
-
 void IAXAccount::serialize(Conf::YamlEmitter &emitter)
 {
     Conf::MappingNode accountmap(NULL);
@@ -142,8 +135,8 @@ std::map<std::string, std::string> IAXAccount::getAccountDetails() const
 void IAXAccount::registerVoIPLink()
 {
     try {
-        link_->init();
-        link_->sendRegister(this);
+        link_.init();
+        link_.sendRegister(this);
     } catch (const VoipLinkException &e) {
         ERROR("IAXAccount: %s", e.what());
     }
@@ -153,8 +146,8 @@ void
 IAXAccount::unregisterVoIPLink()
 {
     try {
-        link_->sendUnregister(this);
-        link_->terminate();
+        link_.sendUnregister(this);
+        link_.terminate();
     } catch (const VoipLinkException &e) {
         ERROR("IAXAccount: %s", e.what());
     }
@@ -171,5 +164,5 @@ IAXAccount::loadConfig()
 
 VoIPLink* IAXAccount::getVoIPLink()
 {
-    return link_;
+    return &link_;
 }
diff --git a/daemon/src/iax/iaxaccount.h b/daemon/src/iax/iaxaccount.h
index 8d2e4fd770..35871972bb 100644
--- a/daemon/src/iax/iaxaccount.h
+++ b/daemon/src/iax/iaxaccount.h
@@ -32,9 +32,7 @@
 #define IAXACCOUNT_H
 
 #include "account.h"
-#include "noncopyable.h"
-
-class IAXVoIPLink;
+#include "iaxvoiplink.h"
 
 /**
  * @file: iaxaccount.h
@@ -43,7 +41,6 @@ class IAXVoIPLink;
 class IAXAccount : public Account {
     public:
         IAXAccount(const std::string& accountID);
-        ~IAXAccount();
 
         virtual void serialize(Conf::YamlEmitter &emitter);
         virtual void unserialize(const Conf::MappingNode &map);
@@ -66,10 +63,9 @@ class IAXAccount : public Account {
         }
 
     private:
-        NON_COPYABLE(IAXAccount);
          // Account login information: password
         std::string password_;
-        IAXVoIPLink *link_;
+        IAXVoIPLink link_;
         virtual VoIPLink* getVoIPLink();
 };
 
-- 
GitLab