https://issues.apache.org/activemq/browse/AMQCPP-222

git-svn-id: https://svn.apache.org/repos/asf/activemq/activemq-cpp/branches/activemq-cpp-2.x@743116 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQBlobMessage.h b/src/main/activemq/connector/openwire/commands/ActiveMQBlobMessage.h
index 285b7ad..c0ae88a 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQBlobMessage.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQBlobMessage.h
@@ -27,6 +27,7 @@
 #include <activemq/connector/openwire/commands/ActiveMQMessageBase.h>
 #include <cms/Message.h>
 #include <string>
+#include <memory>
 
 namespace activemq {
 namespace connector {
@@ -61,9 +62,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQBlobMessage* cloneDataStructure() const {
-            ActiveMQBlobMessage* message = new ActiveMQBlobMessage();
+            std::auto_ptr<ActiveMQBlobMessage> message( new ActiveMQBlobMessage() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h b/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h
index baad726..ae1cb66 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h
@@ -32,6 +32,7 @@
 #include <cms/BytesMessage.h>
 #include <vector>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -58,9 +59,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQBytesMessage* cloneDataStructure() const {
-            ActiveMQBytesMessage* message = new ActiveMQBytesMessage();
+            std::auto_ptr<ActiveMQBytesMessage> message( new ActiveMQBytesMessage() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h b/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h
index 7fd476c..ac1374f 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h
@@ -30,6 +30,7 @@
 #include <cms/MapMessage.h>
 #include <vector>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -70,9 +71,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQMapMessage* cloneDataStructure() const {
-            ActiveMQMapMessage* message = new ActiveMQMapMessage();
+            std::auto_ptr<ActiveMQMapMessage> message( new ActiveMQMapMessage() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h b/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h
index 817f197..0e79ffe 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h
@@ -20,6 +20,7 @@
 
 #include <activemq/util/Config.h>
 #include <activemq/connector/openwire/commands/ActiveMQMessageBase.h>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -55,9 +56,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQMessage* cloneDataStructure() const {
-            ActiveMQMessage* message = new ActiveMQMessage();
+            std::auto_ptr<ActiveMQMessage> message( new ActiveMQMessage() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQObjectMessage.h b/src/main/activemq/connector/openwire/commands/ActiveMQObjectMessage.h
index 3a71158..f538532 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQObjectMessage.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQObjectMessage.h
@@ -26,6 +26,7 @@
 #include <activemq/connector/openwire/commands/ActiveMQMessageBase.h>
 #include <cms/ObjectMessage.h>
 #include <activemq/util/Config.h>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -52,9 +53,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQObjectMessage* cloneDataStructure() const {
-            ActiveMQObjectMessage* message = new ActiveMQObjectMessage();
+            std::auto_ptr<ActiveMQObjectMessage> message( new ActiveMQObjectMessage() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQQueue.h b/src/main/activemq/connector/openwire/commands/ActiveMQQueue.h
index 4909685..63e0d95 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQQueue.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQQueue.h
@@ -30,6 +30,7 @@
 #include <cms/Queue.h>
 #include <vector>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -56,9 +57,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQQueue* cloneDataStructure() const {
-            ActiveMQQueue* message = new ActiveMQQueue();
+            std::auto_ptr<ActiveMQQueue> message( new ActiveMQQueue() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQStreamMessage.h b/src/main/activemq/connector/openwire/commands/ActiveMQStreamMessage.h
index e1ef2c5..2db73ff 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQStreamMessage.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQStreamMessage.h
@@ -26,6 +26,7 @@
 #include <activemq/util/Config.h>
 #include <activemq/connector/openwire/commands/ActiveMQMessage.h>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -50,9 +51,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQStreamMessage* cloneDataStructure() const {
-            ActiveMQStreamMessage* message = new ActiveMQStreamMessage();
+            std::auto_ptr<ActiveMQStreamMessage> message( new ActiveMQStreamMessage() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQTempQueue.h b/src/main/activemq/connector/openwire/commands/ActiveMQTempQueue.h
index af28c96..af5f7b8 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQTempQueue.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQTempQueue.h
@@ -28,6 +28,7 @@
 #include <cms/TemporaryQueue.h>
 #include <vector>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -54,9 +55,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQTempQueue* cloneDataStructure() const {
-            ActiveMQTempQueue* message = new ActiveMQTempQueue();
+            std::auto_ptr<ActiveMQTempQueue> message( new ActiveMQTempQueue() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQTempTopic.h b/src/main/activemq/connector/openwire/commands/ActiveMQTempTopic.h
index abe7cc4..d3a98ca 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQTempTopic.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQTempTopic.h
@@ -28,6 +28,7 @@
 #include <cms/TemporaryTopic.h>
 #include <vector>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -54,9 +55,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQTempTopic* cloneDataStructure() const {
-            ActiveMQTempTopic* message = new ActiveMQTempTopic();
+            std::auto_ptr<ActiveMQTempTopic> message( new ActiveMQTempTopic() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.h b/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.h
index 8fe40b8..8ba37ef 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.h
@@ -28,6 +28,7 @@
 #include <cms/TextMessage.h>
 #include <vector>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -53,9 +54,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQTextMessage* cloneDataStructure() const {
-            ActiveMQTextMessage* message = new ActiveMQTextMessage();
+            std::auto_ptr<ActiveMQTextMessage> message( new ActiveMQTextMessage() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/ActiveMQTopic.h b/src/main/activemq/connector/openwire/commands/ActiveMQTopic.h
index 56dc944..b043538 100644
--- a/src/main/activemq/connector/openwire/commands/ActiveMQTopic.h
+++ b/src/main/activemq/connector/openwire/commands/ActiveMQTopic.h
@@ -30,6 +30,7 @@
 #include <cms/Topic.h>
 #include <vector>
 #include <string>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -56,9 +57,9 @@
          * @returns new copy of this object.
          */
         virtual ActiveMQTopic* cloneDataStructure() const {
-            ActiveMQTopic* message = new ActiveMQTopic();
+            std::auto_ptr<ActiveMQTopic> message( new ActiveMQTopic() );
             message->copyDataStructure( this );
-            return message;
+            return message.release();
         }
 
         /**
diff --git a/src/main/activemq/connector/openwire/commands/BrokerId.cpp b/src/main/activemq/connector/openwire/commands/BrokerId.cpp
index 2b35fd3..9e1fcc9 100644
--- a/src/main/activemq/connector/openwire/commands/BrokerId.cpp
+++ b/src/main/activemq/connector/openwire/commands/BrokerId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/BrokerId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 BrokerId* BrokerId::cloneDataStructure() const {
-    BrokerId* brokerId = new BrokerId();
+    std::auto_ptr<BrokerId> brokerId( new BrokerId() );
 
     // Copy the data from the base class or classes
     brokerId->copyDataStructure( this );
 
-    return brokerId;
+    return brokerId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/BrokerInfo.cpp b/src/main/activemq/connector/openwire/commands/BrokerInfo.cpp
index 82351f8..a310bb9 100644
--- a/src/main/activemq/connector/openwire/commands/BrokerInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/BrokerInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/BrokerInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -63,12 +64,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 BrokerInfo* BrokerInfo::cloneDataStructure() const {
-    BrokerInfo* brokerInfo = new BrokerInfo();
+    std::auto_ptr<BrokerInfo> brokerInfo( new BrokerInfo() );
 
     // Copy the data from the base class or classes
     brokerInfo->copyDataStructure( this );
 
-    return brokerInfo;
+    return brokerInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ConnectionControl.cpp b/src/main/activemq/connector/openwire/commands/ConnectionControl.cpp
index 9ee10a0..6690cca 100644
--- a/src/main/activemq/connector/openwire/commands/ConnectionControl.cpp
+++ b/src/main/activemq/connector/openwire/commands/ConnectionControl.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ConnectionControl.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -53,12 +54,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionControl* ConnectionControl::cloneDataStructure() const {
-    ConnectionControl* connectionControl = new ConnectionControl();
+    std::auto_ptr<ConnectionControl> connectionControl( new ConnectionControl() );
 
     // Copy the data from the base class or classes
     connectionControl->copyDataStructure( this );
 
-    return connectionControl;
+    return connectionControl.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ConnectionError.cpp b/src/main/activemq/connector/openwire/commands/ConnectionError.cpp
index 202c7d0..6423d24 100644
--- a/src/main/activemq/connector/openwire/commands/ConnectionError.cpp
+++ b/src/main/activemq/connector/openwire/commands/ConnectionError.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ConnectionError.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -52,12 +53,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionError* ConnectionError::cloneDataStructure() const {
-    ConnectionError* connectionError = new ConnectionError();
+    std::auto_ptr<ConnectionError> connectionError( new ConnectionError() );
 
     // Copy the data from the base class or classes
     connectionError->copyDataStructure( this );
 
-    return connectionError;
+    return connectionError.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ConnectionId.cpp b/src/main/activemq/connector/openwire/commands/ConnectionId.cpp
index f5923b7..6427a17 100644
--- a/src/main/activemq/connector/openwire/commands/ConnectionId.cpp
+++ b/src/main/activemq/connector/openwire/commands/ConnectionId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ConnectionId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionId* ConnectionId::cloneDataStructure() const {
-    ConnectionId* connectionId = new ConnectionId();
+    std::auto_ptr<ConnectionId> connectionId( new ConnectionId() );
 
     // Copy the data from the base class or classes
     connectionId->copyDataStructure( this );
 
-    return connectionId;
+    return connectionId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ConnectionInfo.cpp b/src/main/activemq/connector/openwire/commands/ConnectionInfo.cpp
index 09939d1..1d99adf 100644
--- a/src/main/activemq/connector/openwire/commands/ConnectionInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/ConnectionInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ConnectionInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -59,12 +60,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionInfo* ConnectionInfo::cloneDataStructure() const {
-    ConnectionInfo* connectionInfo = new ConnectionInfo();
+    std::auto_ptr<ConnectionInfo> connectionInfo( new ConnectionInfo() );
 
     // Copy the data from the base class or classes
     connectionInfo->copyDataStructure( this );
 
-    return connectionInfo;
+    return connectionInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ConsumerControl.cpp b/src/main/activemq/connector/openwire/commands/ConsumerControl.cpp
index 843d9d5..1fb67e2 100644
--- a/src/main/activemq/connector/openwire/commands/ConsumerControl.cpp
+++ b/src/main/activemq/connector/openwire/commands/ConsumerControl.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ConsumerControl.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -55,12 +56,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ConsumerControl* ConsumerControl::cloneDataStructure() const {
-    ConsumerControl* consumerControl = new ConsumerControl();
+    std::auto_ptr<ConsumerControl> consumerControl( new ConsumerControl() );
 
     // Copy the data from the base class or classes
     consumerControl->copyDataStructure( this );
 
-    return consumerControl;
+    return consumerControl.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ConsumerId.cpp b/src/main/activemq/connector/openwire/commands/ConsumerId.cpp
index 0589cd1..8712857 100644
--- a/src/main/activemq/connector/openwire/commands/ConsumerId.cpp
+++ b/src/main/activemq/connector/openwire/commands/ConsumerId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ConsumerId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -51,12 +52,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ConsumerId* ConsumerId::cloneDataStructure() const {
-    ConsumerId* consumerId = new ConsumerId();
+    std::auto_ptr<ConsumerId> consumerId( new ConsumerId() );
 
     // Copy the data from the base class or classes
     consumerId->copyDataStructure( this );
 
-    return consumerId;
+    return consumerId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ConsumerInfo.cpp b/src/main/activemq/connector/openwire/commands/ConsumerInfo.cpp
index 9ae7d87..cb23c99 100644
--- a/src/main/activemq/connector/openwire/commands/ConsumerInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/ConsumerInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ConsumerInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -70,12 +71,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ConsumerInfo* ConsumerInfo::cloneDataStructure() const {
-    ConsumerInfo* consumerInfo = new ConsumerInfo();
+    std::auto_ptr<ConsumerInfo> consumerInfo( new ConsumerInfo() );
 
     // Copy the data from the base class or classes
     consumerInfo->copyDataStructure( this );
 
-    return consumerInfo;
+    return consumerInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ControlCommand.cpp b/src/main/activemq/connector/openwire/commands/ControlCommand.cpp
index 66551ff..eda5844 100644
--- a/src/main/activemq/connector/openwire/commands/ControlCommand.cpp
+++ b/src/main/activemq/connector/openwire/commands/ControlCommand.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ControlCommand.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ControlCommand* ControlCommand::cloneDataStructure() const {
-    ControlCommand* controlCommand = new ControlCommand();
+    std::auto_ptr<ControlCommand> controlCommand( new ControlCommand() );
 
     // Copy the data from the base class or classes
     controlCommand->copyDataStructure( this );
 
-    return controlCommand;
+    return controlCommand.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/DataArrayResponse.cpp b/src/main/activemq/connector/openwire/commands/DataArrayResponse.cpp
index d637ea1..02374fc 100644
--- a/src/main/activemq/connector/openwire/commands/DataArrayResponse.cpp
+++ b/src/main/activemq/connector/openwire/commands/DataArrayResponse.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/DataArrayResponse.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -51,12 +52,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 DataArrayResponse* DataArrayResponse::cloneDataStructure() const {
-    DataArrayResponse* dataArrayResponse = new DataArrayResponse();
+    std::auto_ptr<DataArrayResponse> dataArrayResponse( new DataArrayResponse() );
 
     // Copy the data from the base class or classes
     dataArrayResponse->copyDataStructure( this );
 
-    return dataArrayResponse;
+    return dataArrayResponse.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/DataResponse.cpp b/src/main/activemq/connector/openwire/commands/DataResponse.cpp
index a8c4266..af614f5 100644
--- a/src/main/activemq/connector/openwire/commands/DataResponse.cpp
+++ b/src/main/activemq/connector/openwire/commands/DataResponse.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/DataResponse.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -50,12 +51,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 DataResponse* DataResponse::cloneDataStructure() const {
-    DataResponse* dataResponse = new DataResponse();
+    std::auto_ptr<DataResponse> dataResponse( new DataResponse() );
 
     // Copy the data from the base class or classes
     dataResponse->copyDataStructure( this );
 
-    return dataResponse;
+    return dataResponse.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/DestinationInfo.cpp b/src/main/activemq/connector/openwire/commands/DestinationInfo.cpp
index b72f5a6..0267d7a 100644
--- a/src/main/activemq/connector/openwire/commands/DestinationInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/DestinationInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/DestinationInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -57,12 +58,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 DestinationInfo* DestinationInfo::cloneDataStructure() const {
-    DestinationInfo* destinationInfo = new DestinationInfo();
+    std::auto_ptr<DestinationInfo> destinationInfo( new DestinationInfo() );
 
     // Copy the data from the base class or classes
     destinationInfo->copyDataStructure( this );
 
-    return destinationInfo;
+    return destinationInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/DiscoveryEvent.cpp b/src/main/activemq/connector/openwire/commands/DiscoveryEvent.cpp
index a947b32..ae8d3be 100644
--- a/src/main/activemq/connector/openwire/commands/DiscoveryEvent.cpp
+++ b/src/main/activemq/connector/openwire/commands/DiscoveryEvent.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/DiscoveryEvent.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -50,12 +51,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 DiscoveryEvent* DiscoveryEvent::cloneDataStructure() const {
-    DiscoveryEvent* discoveryEvent = new DiscoveryEvent();
+    std::auto_ptr<DiscoveryEvent> discoveryEvent( new DiscoveryEvent() );
 
     // Copy the data from the base class or classes
     discoveryEvent->copyDataStructure( this );
 
-    return discoveryEvent;
+    return discoveryEvent.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ExceptionResponse.cpp b/src/main/activemq/connector/openwire/commands/ExceptionResponse.cpp
index c10d8f9..67851d3 100644
--- a/src/main/activemq/connector/openwire/commands/ExceptionResponse.cpp
+++ b/src/main/activemq/connector/openwire/commands/ExceptionResponse.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ExceptionResponse.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -50,12 +51,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ExceptionResponse* ExceptionResponse::cloneDataStructure() const {
-    ExceptionResponse* exceptionResponse = new ExceptionResponse();
+    std::auto_ptr<ExceptionResponse> exceptionResponse( new ExceptionResponse() );
 
     // Copy the data from the base class or classes
     exceptionResponse->copyDataStructure( this );
 
-    return exceptionResponse;
+    return exceptionResponse.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/FlushCommand.cpp b/src/main/activemq/connector/openwire/commands/FlushCommand.cpp
index c2de612..41d04d3 100644
--- a/src/main/activemq/connector/openwire/commands/FlushCommand.cpp
+++ b/src/main/activemq/connector/openwire/commands/FlushCommand.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/FlushCommand.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -48,12 +49,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 FlushCommand* FlushCommand::cloneDataStructure() const {
-    FlushCommand* flushCommand = new FlushCommand();
+    std::auto_ptr<FlushCommand> flushCommand( new FlushCommand() );
 
     // Copy the data from the base class or classes
     flushCommand->copyDataStructure( this );
 
-    return flushCommand;
+    return flushCommand.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/IntegerResponse.cpp b/src/main/activemq/connector/openwire/commands/IntegerResponse.cpp
index 2106e8a..4cfdb12 100644
--- a/src/main/activemq/connector/openwire/commands/IntegerResponse.cpp
+++ b/src/main/activemq/connector/openwire/commands/IntegerResponse.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/IntegerResponse.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 IntegerResponse* IntegerResponse::cloneDataStructure() const {
-    IntegerResponse* integerResponse = new IntegerResponse();
+    std::auto_ptr<IntegerResponse> integerResponse( new IntegerResponse() );
 
     // Copy the data from the base class or classes
     integerResponse->copyDataStructure( this );
 
-    return integerResponse;
+    return integerResponse.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/JournalQueueAck.cpp b/src/main/activemq/connector/openwire/commands/JournalQueueAck.cpp
index 992dd75..1b8cc44 100644
--- a/src/main/activemq/connector/openwire/commands/JournalQueueAck.cpp
+++ b/src/main/activemq/connector/openwire/commands/JournalQueueAck.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/JournalQueueAck.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -52,12 +53,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 JournalQueueAck* JournalQueueAck::cloneDataStructure() const {
-    JournalQueueAck* journalQueueAck = new JournalQueueAck();
+    std::auto_ptr<JournalQueueAck> journalQueueAck( new JournalQueueAck() );
 
     // Copy the data from the base class or classes
     journalQueueAck->copyDataStructure( this );
 
-    return journalQueueAck;
+    return journalQueueAck.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/JournalTopicAck.cpp b/src/main/activemq/connector/openwire/commands/JournalTopicAck.cpp
index 3edd0bf..0883ad4 100644
--- a/src/main/activemq/connector/openwire/commands/JournalTopicAck.cpp
+++ b/src/main/activemq/connector/openwire/commands/JournalTopicAck.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/JournalTopicAck.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -57,12 +58,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 JournalTopicAck* JournalTopicAck::cloneDataStructure() const {
-    JournalTopicAck* journalTopicAck = new JournalTopicAck();
+    std::auto_ptr<JournalTopicAck> journalTopicAck( new JournalTopicAck() );
 
     // Copy the data from the base class or classes
     journalTopicAck->copyDataStructure( this );
 
-    return journalTopicAck;
+    return journalTopicAck.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/JournalTrace.cpp b/src/main/activemq/connector/openwire/commands/JournalTrace.cpp
index 2e72133..6985d80 100644
--- a/src/main/activemq/connector/openwire/commands/JournalTrace.cpp
+++ b/src/main/activemq/connector/openwire/commands/JournalTrace.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/JournalTrace.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 JournalTrace* JournalTrace::cloneDataStructure() const {
-    JournalTrace* journalTrace = new JournalTrace();
+    std::auto_ptr<JournalTrace> journalTrace( new JournalTrace() );
 
     // Copy the data from the base class or classes
     journalTrace->copyDataStructure( this );
 
-    return journalTrace;
+    return journalTrace.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/JournalTransaction.cpp b/src/main/activemq/connector/openwire/commands/JournalTransaction.cpp
index b05df30..27a2a50 100644
--- a/src/main/activemq/connector/openwire/commands/JournalTransaction.cpp
+++ b/src/main/activemq/connector/openwire/commands/JournalTransaction.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/JournalTransaction.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -52,12 +53,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 JournalTransaction* JournalTransaction::cloneDataStructure() const {
-    JournalTransaction* journalTransaction = new JournalTransaction();
+    std::auto_ptr<JournalTransaction> journalTransaction( new JournalTransaction() );
 
     // Copy the data from the base class or classes
     journalTransaction->copyDataStructure( this );
 
-    return journalTransaction;
+    return journalTransaction.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/KeepAliveInfo.cpp b/src/main/activemq/connector/openwire/commands/KeepAliveInfo.cpp
index 4f6ac1d..b85dad7 100644
--- a/src/main/activemq/connector/openwire/commands/KeepAliveInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/KeepAliveInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/KeepAliveInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -48,12 +49,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 KeepAliveInfo* KeepAliveInfo::cloneDataStructure() const {
-    KeepAliveInfo* keepAliveInfo = new KeepAliveInfo();
+    std::auto_ptr<KeepAliveInfo> keepAliveInfo( new KeepAliveInfo() );
 
     // Copy the data from the base class or classes
     keepAliveInfo->copyDataStructure( this );
 
-    return keepAliveInfo;
+    return keepAliveInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/LastPartialCommand.cpp b/src/main/activemq/connector/openwire/commands/LastPartialCommand.cpp
index 7f68e9b..7f49bd8 100644
--- a/src/main/activemq/connector/openwire/commands/LastPartialCommand.cpp
+++ b/src/main/activemq/connector/openwire/commands/LastPartialCommand.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/LastPartialCommand.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -48,12 +49,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 LastPartialCommand* LastPartialCommand::cloneDataStructure() const {
-    LastPartialCommand* lastPartialCommand = new LastPartialCommand();
+    std::auto_ptr<LastPartialCommand> lastPartialCommand( new LastPartialCommand() );
 
     // Copy the data from the base class or classes
     lastPartialCommand->copyDataStructure( this );
 
-    return lastPartialCommand;
+    return lastPartialCommand.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/LocalTransactionId.cpp b/src/main/activemq/connector/openwire/commands/LocalTransactionId.cpp
index b884e5b..7c26c52 100644
--- a/src/main/activemq/connector/openwire/commands/LocalTransactionId.cpp
+++ b/src/main/activemq/connector/openwire/commands/LocalTransactionId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/LocalTransactionId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -51,12 +52,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 LocalTransactionId* LocalTransactionId::cloneDataStructure() const {
-    LocalTransactionId* localTransactionId = new LocalTransactionId();
+    std::auto_ptr<LocalTransactionId> localTransactionId( new LocalTransactionId() );
 
     // Copy the data from the base class or classes
     localTransactionId->copyDataStructure( this );
 
-    return localTransactionId;
+    return localTransactionId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/Message.cpp b/src/main/activemq/connector/openwire/commands/Message.cpp
index ca11f46..cbf57ee 100644
--- a/src/main/activemq/connector/openwire/commands/Message.cpp
+++ b/src/main/activemq/connector/openwire/commands/Message.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/Message.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -88,12 +89,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 Message* Message::cloneDataStructure() const {
-    Message* message = new Message();
+    std::auto_ptr<Message> message( new Message() );
 
     // Copy the data from the base class or classes
     message->copyDataStructure( this );
 
-    return message;
+    return message.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/MessageAck.cpp b/src/main/activemq/connector/openwire/commands/MessageAck.cpp
index 41e2a34..d3e3a7a 100644
--- a/src/main/activemq/connector/openwire/commands/MessageAck.cpp
+++ b/src/main/activemq/connector/openwire/commands/MessageAck.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/MessageAck.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -60,12 +61,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 MessageAck* MessageAck::cloneDataStructure() const {
-    MessageAck* messageAck = new MessageAck();
+    std::auto_ptr<MessageAck> messageAck( new MessageAck() );
 
     // Copy the data from the base class or classes
     messageAck->copyDataStructure( this );
 
-    return messageAck;
+    return messageAck.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/MessageDispatch.cpp b/src/main/activemq/connector/openwire/commands/MessageDispatch.cpp
index 4098da5..556ead4 100644
--- a/src/main/activemq/connector/openwire/commands/MessageDispatch.cpp
+++ b/src/main/activemq/connector/openwire/commands/MessageDispatch.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/MessageDispatch.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -55,12 +56,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 MessageDispatch* MessageDispatch::cloneDataStructure() const {
-    MessageDispatch* messageDispatch = new MessageDispatch();
+    std::auto_ptr<MessageDispatch> messageDispatch( new MessageDispatch() );
 
     // Copy the data from the base class or classes
     messageDispatch->copyDataStructure( this );
 
-    return messageDispatch;
+    return messageDispatch.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/MessageDispatchNotification.cpp b/src/main/activemq/connector/openwire/commands/MessageDispatchNotification.cpp
index 7d679d3..c24d365 100644
--- a/src/main/activemq/connector/openwire/commands/MessageDispatchNotification.cpp
+++ b/src/main/activemq/connector/openwire/commands/MessageDispatchNotification.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/MessageDispatchNotification.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -55,12 +56,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 MessageDispatchNotification* MessageDispatchNotification::cloneDataStructure() const {
-    MessageDispatchNotification* messageDispatchNotification = new MessageDispatchNotification();
+    std::auto_ptr<MessageDispatchNotification> messageDispatchNotification( new MessageDispatchNotification() );
 
     // Copy the data from the base class or classes
     messageDispatchNotification->copyDataStructure( this );
 
-    return messageDispatchNotification;
+    return messageDispatchNotification.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/MessageId.cpp b/src/main/activemq/connector/openwire/commands/MessageId.cpp
index d1319e1..5505683 100644
--- a/src/main/activemq/connector/openwire/commands/MessageId.cpp
+++ b/src/main/activemq/connector/openwire/commands/MessageId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/MessageId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -52,12 +53,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 MessageId* MessageId::cloneDataStructure() const {
-    MessageId* messageId = new MessageId();
+    std::auto_ptr<MessageId> messageId( new MessageId() );
 
     // Copy the data from the base class or classes
     messageId->copyDataStructure( this );
 
-    return messageId;
+    return messageId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/MessagePull.cpp b/src/main/activemq/connector/openwire/commands/MessagePull.cpp
index 49af3f7..3146ddd 100644
--- a/src/main/activemq/connector/openwire/commands/MessagePull.cpp
+++ b/src/main/activemq/connector/openwire/commands/MessagePull.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/MessagePull.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -56,12 +57,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 MessagePull* MessagePull::cloneDataStructure() const {
-    MessagePull* messagePull = new MessagePull();
+    std::auto_ptr<MessagePull> messagePull( new MessagePull() );
 
     // Copy the data from the base class or classes
     messagePull->copyDataStructure( this );
 
-    return messagePull;
+    return messagePull.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/NetworkBridgeFilter.cpp b/src/main/activemq/connector/openwire/commands/NetworkBridgeFilter.cpp
index 8d4e243..f72bd69 100644
--- a/src/main/activemq/connector/openwire/commands/NetworkBridgeFilter.cpp
+++ b/src/main/activemq/connector/openwire/commands/NetworkBridgeFilter.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/NetworkBridgeFilter.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -51,12 +52,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 NetworkBridgeFilter* NetworkBridgeFilter::cloneDataStructure() const {
-    NetworkBridgeFilter* networkBridgeFilter = new NetworkBridgeFilter();
+    std::auto_ptr<NetworkBridgeFilter> networkBridgeFilter( new NetworkBridgeFilter() );
 
     // Copy the data from the base class or classes
     networkBridgeFilter->copyDataStructure( this );
 
-    return networkBridgeFilter;
+    return networkBridgeFilter.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/PartialCommand.cpp b/src/main/activemq/connector/openwire/commands/PartialCommand.cpp
index a4a21ff..08b5240 100644
--- a/src/main/activemq/connector/openwire/commands/PartialCommand.cpp
+++ b/src/main/activemq/connector/openwire/commands/PartialCommand.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/PartialCommand.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 PartialCommand* PartialCommand::cloneDataStructure() const {
-    PartialCommand* partialCommand = new PartialCommand();
+    std::auto_ptr<PartialCommand> partialCommand( new PartialCommand() );
 
     // Copy the data from the base class or classes
     partialCommand->copyDataStructure( this );
 
-    return partialCommand;
+    return partialCommand.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ProducerAck.cpp b/src/main/activemq/connector/openwire/commands/ProducerAck.cpp
index cc05ebd..535f4f0 100644
--- a/src/main/activemq/connector/openwire/commands/ProducerAck.cpp
+++ b/src/main/activemq/connector/openwire/commands/ProducerAck.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ProducerAck.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -51,12 +52,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ProducerAck* ProducerAck::cloneDataStructure() const {
-    ProducerAck* producerAck = new ProducerAck();
+    std::auto_ptr<ProducerAck> producerAck( new ProducerAck() );
 
     // Copy the data from the base class or classes
     producerAck->copyDataStructure( this );
 
-    return producerAck;
+    return producerAck.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ProducerId.cpp b/src/main/activemq/connector/openwire/commands/ProducerId.cpp
index 86db67d..f8b7e35 100644
--- a/src/main/activemq/connector/openwire/commands/ProducerId.cpp
+++ b/src/main/activemq/connector/openwire/commands/ProducerId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ProducerId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -51,12 +52,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ProducerId* ProducerId::cloneDataStructure() const {
-    ProducerId* producerId = new ProducerId();
+    std::auto_ptr<ProducerId> producerId( new ProducerId() );
 
     // Copy the data from the base class or classes
     producerId->copyDataStructure( this );
 
-    return producerId;
+    return producerId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ProducerInfo.cpp b/src/main/activemq/connector/openwire/commands/ProducerInfo.cpp
index 59a0ef5..9d1b094 100644
--- a/src/main/activemq/connector/openwire/commands/ProducerInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/ProducerInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ProducerInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -57,12 +58,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ProducerInfo* ProducerInfo::cloneDataStructure() const {
-    ProducerInfo* producerInfo = new ProducerInfo();
+    std::auto_ptr<ProducerInfo> producerInfo( new ProducerInfo() );
 
     // Copy the data from the base class or classes
     producerInfo->copyDataStructure( this );
 
-    return producerInfo;
+    return producerInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/RemoveInfo.cpp b/src/main/activemq/connector/openwire/commands/RemoveInfo.cpp
index c5d2c95..6c6350d 100644
--- a/src/main/activemq/connector/openwire/commands/RemoveInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/RemoveInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/RemoveInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -50,12 +51,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 RemoveInfo* RemoveInfo::cloneDataStructure() const {
-    RemoveInfo* removeInfo = new RemoveInfo();
+    std::auto_ptr<RemoveInfo> removeInfo( new RemoveInfo() );
 
     // Copy the data from the base class or classes
     removeInfo->copyDataStructure( this );
 
-    return removeInfo;
+    return removeInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/RemoveSubscriptionInfo.cpp b/src/main/activemq/connector/openwire/commands/RemoveSubscriptionInfo.cpp
index 61604b9..27d0194 100644
--- a/src/main/activemq/connector/openwire/commands/RemoveSubscriptionInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/RemoveSubscriptionInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/RemoveSubscriptionInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -52,12 +53,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 RemoveSubscriptionInfo* RemoveSubscriptionInfo::cloneDataStructure() const {
-    RemoveSubscriptionInfo* removeSubscriptionInfo = new RemoveSubscriptionInfo();
+    std::auto_ptr<RemoveSubscriptionInfo> removeSubscriptionInfo( new RemoveSubscriptionInfo() );
 
     // Copy the data from the base class or classes
     removeSubscriptionInfo->copyDataStructure( this );
 
-    return removeSubscriptionInfo;
+    return removeSubscriptionInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ReplayCommand.cpp b/src/main/activemq/connector/openwire/commands/ReplayCommand.cpp
index f3f355b..63c2a1d 100644
--- a/src/main/activemq/connector/openwire/commands/ReplayCommand.cpp
+++ b/src/main/activemq/connector/openwire/commands/ReplayCommand.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ReplayCommand.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -50,12 +51,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ReplayCommand* ReplayCommand::cloneDataStructure() const {
-    ReplayCommand* replayCommand = new ReplayCommand();
+    std::auto_ptr<ReplayCommand> replayCommand( new ReplayCommand() );
 
     // Copy the data from the base class or classes
     replayCommand->copyDataStructure( this );
 
-    return replayCommand;
+    return replayCommand.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/Response.cpp b/src/main/activemq/connector/openwire/commands/Response.cpp
index a8fc513..a819bd8 100644
--- a/src/main/activemq/connector/openwire/commands/Response.cpp
+++ b/src/main/activemq/connector/openwire/commands/Response.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/Response.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 Response* Response::cloneDataStructure() const {
-    Response* response = new Response();
+    std::auto_ptr<Response> response( new Response() );
 
     // Copy the data from the base class or classes
     response->copyDataStructure( this );
 
-    return response;
+    return response.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/SessionId.cpp b/src/main/activemq/connector/openwire/commands/SessionId.cpp
index a01ddaf..ee378f9 100644
--- a/src/main/activemq/connector/openwire/commands/SessionId.cpp
+++ b/src/main/activemq/connector/openwire/commands/SessionId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/SessionId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -50,12 +51,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 SessionId* SessionId::cloneDataStructure() const {
-    SessionId* sessionId = new SessionId();
+    std::auto_ptr<SessionId> sessionId( new SessionId() );
 
     // Copy the data from the base class or classes
     sessionId->copyDataStructure( this );
 
-    return sessionId;
+    return sessionId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/SessionInfo.cpp b/src/main/activemq/connector/openwire/commands/SessionInfo.cpp
index a2ac8b5..fa91db3 100644
--- a/src/main/activemq/connector/openwire/commands/SessionInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/SessionInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/SessionInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -50,12 +51,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 SessionInfo* SessionInfo::cloneDataStructure() const {
-    SessionInfo* sessionInfo = new SessionInfo();
+    std::auto_ptr<SessionInfo> sessionInfo( new SessionInfo() );
 
     // Copy the data from the base class or classes
     sessionInfo->copyDataStructure( this );
 
-    return sessionInfo;
+    return sessionInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/ShutdownInfo.cpp b/src/main/activemq/connector/openwire/commands/ShutdownInfo.cpp
index c62bc68..3165c33 100644
--- a/src/main/activemq/connector/openwire/commands/ShutdownInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/ShutdownInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/ShutdownInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -48,12 +49,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ShutdownInfo* ShutdownInfo::cloneDataStructure() const {
-    ShutdownInfo* shutdownInfo = new ShutdownInfo();
+    std::auto_ptr<ShutdownInfo> shutdownInfo( new ShutdownInfo() );
 
     // Copy the data from the base class or classes
     shutdownInfo->copyDataStructure( this );
 
-    return shutdownInfo;
+    return shutdownInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/SubscriptionInfo.cpp b/src/main/activemq/connector/openwire/commands/SubscriptionInfo.cpp
index c5dcdd6..4c2be66 100644
--- a/src/main/activemq/connector/openwire/commands/SubscriptionInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/SubscriptionInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/SubscriptionInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -55,12 +56,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 SubscriptionInfo* SubscriptionInfo::cloneDataStructure() const {
-    SubscriptionInfo* subscriptionInfo = new SubscriptionInfo();
+    std::auto_ptr<SubscriptionInfo> subscriptionInfo( new SubscriptionInfo() );
 
     // Copy the data from the base class or classes
     subscriptionInfo->copyDataStructure( this );
 
-    return subscriptionInfo;
+    return subscriptionInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/TransactionId.cpp b/src/main/activemq/connector/openwire/commands/TransactionId.cpp
index b37faff..15d415d 100644
--- a/src/main/activemq/connector/openwire/commands/TransactionId.cpp
+++ b/src/main/activemq/connector/openwire/commands/TransactionId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/TransactionId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -48,12 +49,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 TransactionId* TransactionId::cloneDataStructure() const {
-    TransactionId* transactionId = new TransactionId();
+    std::auto_ptr<TransactionId> transactionId( new TransactionId() );
 
     // Copy the data from the base class or classes
     transactionId->copyDataStructure( this );
 
-    return transactionId;
+    return transactionId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/TransactionInfo.cpp b/src/main/activemq/connector/openwire/commands/TransactionInfo.cpp
index 1488820..e113769 100644
--- a/src/main/activemq/connector/openwire/commands/TransactionInfo.cpp
+++ b/src/main/activemq/connector/openwire/commands/TransactionInfo.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/TransactionInfo.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -53,12 +54,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 TransactionInfo* TransactionInfo::cloneDataStructure() const {
-    TransactionInfo* transactionInfo = new TransactionInfo();
+    std::auto_ptr<TransactionInfo> transactionInfo( new TransactionInfo() );
 
     // Copy the data from the base class or classes
     transactionInfo->copyDataStructure( this );
 
-    return transactionInfo;
+    return transactionInfo.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/activemq/connector/openwire/commands/XATransactionId.cpp b/src/main/activemq/connector/openwire/commands/XATransactionId.cpp
index 7d98c2f..973d989 100644
--- a/src/main/activemq/connector/openwire/commands/XATransactionId.cpp
+++ b/src/main/activemq/connector/openwire/commands/XATransactionId.cpp
@@ -17,6 +17,7 @@
 #include <activemq/connector/openwire/commands/XATransactionId.h>
 #include <activemq/exceptions/ActiveMQException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <memory>
 
 using namespace std;
 using namespace activemq;
@@ -49,12 +50,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 XATransactionId* XATransactionId::cloneDataStructure() const {
-    XATransactionId* xATransactionId = new XATransactionId();
+    std::auto_ptr<XATransactionId> xATransactionId( new XATransactionId() );
 
     // Copy the data from the base class or classes
     xATransactionId->copyDataStructure( this );
 
-    return xATransactionId;
+    return xATransactionId.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/apache/activemq/openwire/tool/AmqCppClassesGenerator.java b/src/main/java/org/apache/activemq/openwire/tool/AmqCppClassesGenerator.java
index a11dac4..e6aaeab 100644
--- a/src/main/java/org/apache/activemq/openwire/tool/AmqCppClassesGenerator.java
+++ b/src/main/java/org/apache/activemq/openwire/tool/AmqCppClassesGenerator.java
@@ -155,6 +155,7 @@
 out.println("#include <activemq/connector/openwire/commands/"+className+".h>");
 out.println("#include <activemq/exceptions/ActiveMQException.h>");
 out.println("#include <decaf/lang/exceptions/NullPointerException.h>");
+out.println("#include <memory>");
 out.println("");
 out.println("using namespace std;");
 out.println("using namespace activemq;");
@@ -223,12 +224,12 @@
 
     String newInstance = decapitalize( className );
 
-out.println("    "+className+"* "+newInstance+" = new "+className+"();");
+out.println("    std::auto_ptr<"+className+"> "+newInstance+"( new "+className+"() );");
 out.println("");
 out.println("    // Copy the data from the base class or classes");
 out.println("    "+newInstance+"->copyDataStructure( this );");
 out.println("");
-out.println("    return "+newInstance+";");
+out.println("    return "+newInstance+".release();");
 out.println("}");
 
 out.println("");