Added user-written assignment operator and user-written copy constructor 90/33590/1
authorWonkeun Oh <wonkeun.oh@samsung.com>
Mon, 1 Sep 2014 10:28:22 +0000 (19:28 +0900)
committerLi Zhang <li2012.zhang@samsung.com>
Tue, 13 Jan 2015 08:35:10 +0000 (16:35 +0800)
[model] Kiran, B3
[binary_type] PDA
[customer] OPEN
[issue#] N/A
[problem] There is no user-written copy constructor and assignment operator
[cause] There is no user-written copy contructor and assignment operator
[solution] Added user-written assignment operator and user-written copy constructor
[team] Input Framework
[request] N/A
[horizontal_expansion] N/A

Change-Id: If1eaad9d8550fac583b83925cda7c51ce2646f17

ism/src/scim_transaction.cpp

index 1642826..8839fa4 100644 (file)
@@ -74,10 +74,37 @@ public:
             throw Exception ("TransactionHolder::TransactionHolder() Out of memory");
     }
 
+    TransactionHolder (TransactionHolder &other)
+        : m_ref (other.m_ref),
+          m_buffer_size (other.m_buffer_size),
+          m_write_pos (other.m_write_pos),
+          m_buffer ((unsigned char*) malloc (other.m_buffer_size)) {
+        if (!m_buffer)
+            throw Exception ("TransactionHolder::TransactionHolder() Out of memory");
+
+        if (m_buffer_size && m_buffer)
+            memcpy (m_buffer, other.m_buffer, m_buffer_size);
+    }
+
     ~TransactionHolder () {
         free (m_buffer);
     }
 
+    const TransactionHolder & operator = (const TransactionHolder &other) {
+        m_ref = other.m_ref;
+        m_buffer_size = other.m_buffer_size;
+        m_write_pos = other.m_write_pos;
+        free (m_buffer);
+        m_buffer = (unsigned char*) malloc (other.m_buffer_size);
+        if (!m_buffer)
+            throw Exception ("TransactionHolder::TransactionHolder() Out of memory");
+
+        if (m_buffer_size && m_buffer)
+            memcpy (m_buffer, other.m_buffer, m_buffer_size);
+
+        return *this;
+    }
+
     bool valid () const {
         return m_buffer && m_buffer_size;
     }