certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] applications/PyHLA/hla/_rti rtiambassador.cpp


From: certi-cvs
Subject: [certi-cvs] applications/PyHLA/hla/_rti rtiambassador.cpp
Date: Mon, 13 Oct 2008 11:35:21 +0000

CVSROOT:        /sources/certi
Module name:    applications
Changes by:     Petr Gotthard <gotthardp>       08/10/13 11:35:21

Modified files:
        PyHLA/hla/_rti : rtiambassador.cpp 

Log message:
        Removed memory leak: delete[] after RTI::getXXXName() functions.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/PyHLA/hla/_rti/rtiambassador.cpp?cvsroot=certi&r1=1.4&r2=1.5

Patches:
Index: rtiambassador.cpp
===================================================================
RCS file: /sources/certi/applications/PyHLA/hla/_rti/rtiambassador.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- rtiambassador.cpp   12 Oct 2008 13:31:14 -0000      1.4
+++ rtiambassador.cpp   13 Oct 2008 11:35:11 -0000      1.5
@@ -11,7 +11,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
- * $Id: rtiambassador.cpp,v 1.4 2008/10/12 13:31:14 gotthardp Exp $
+ * $Id: rtiambassador.cpp,v 1.5 2008/10/13 11:35:11 gotthardp Exp $
  */
 
 // note: you must include Python.h before any standard headers are included
@@ -2090,9 +2090,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getObjectClassName(theHandle);
+        char *theName = self->ob_rtia->getObjectClassName(theHandle);
 
-        return PyString_FromString(result);
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
+
+        return result;
     }
     CATCH_RTI_EXCEPTION(ObjectClassNotDefined)
     CATCH_RTI_EXCEPTION(FederateNotExecutionMember)
@@ -2141,9 +2144,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getAttributeName(theHandle, whichClass);
+        char *theName = self->ob_rtia->getAttributeName(theHandle, whichClass);
+
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
 
-        return PyString_FromString(result);
+        return result;
     }
     CATCH_RTI_EXCEPTION(ObjectClassNotDefined)
     CATCH_RTI_EXCEPTION(AttributeNotDefined)
@@ -2187,9 +2193,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getInteractionClassName(theHandle);
+        char *theName = self->ob_rtia->getInteractionClassName(theHandle);
+
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
 
-        return PyString_FromString(result);
+        return result;
     }
     CATCH_RTI_EXCEPTION(InteractionClassNotDefined)
     CATCH_RTI_EXCEPTION(FederateNotExecutionMember)
@@ -2238,9 +2247,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getParameterName(theHandle, whichClass);
+        char *theName = self->ob_rtia->getParameterName(theHandle, whichClass);
 
-        return PyString_FromString(result);
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
+
+        return result;
     }
     CATCH_RTI_EXCEPTION(InteractionClassNotDefined)
     CATCH_RTI_EXCEPTION(InteractionParameterNotDefined)
@@ -2284,9 +2296,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getObjectInstanceName(theHandle);
+        char *theName = self->ob_rtia->getObjectInstanceName(theHandle);
+
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
 
-        return PyString_FromString(result);
+        return result;
     }
     CATCH_RTI_EXCEPTION(ObjectNotKnown)
     CATCH_RTI_EXCEPTION(FederateNotExecutionMember)
@@ -2329,9 +2344,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getRoutingSpaceName(theHandle);
+        char *theName = self->ob_rtia->getRoutingSpaceName(theHandle);
 
-        return PyString_FromString(result);
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
+
+        return result;
     }
     CATCH_RTI_EXCEPTION(SpaceNotDefined)
     CATCH_RTI_EXCEPTION(FederateNotExecutionMember)
@@ -2380,9 +2398,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getDimensionName(theHandle, whichSpace);
+        char *theName = self->ob_rtia->getDimensionName(theHandle, whichSpace);
+
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
 
-        return PyString_FromString(result);
+        return result;
     }
     CATCH_RTI_EXCEPTION(SpaceNotDefined)
     CATCH_RTI_EXCEPTION(DimensionNotDefined)
@@ -2498,9 +2519,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getTransportationName(theHandle);
+        char *theName = self->ob_rtia->getTransportationName(theHandle);
 
-        return PyString_FromString(result);
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
+
+        return result;
     }
     CATCH_RTI_EXCEPTION(InvalidTransportationHandle)
     CATCH_RTI_EXCEPTION(FederateNotExecutionMember)
@@ -2543,9 +2567,12 @@
         return NULL;
 
     try {
-        char *result = self->ob_rtia->getOrderingName(theHandle);
+        char *theName = self->ob_rtia->getOrderingName(theHandle);
+
+        PyObject *result = PyString_FromString(theName);
+        delete[] theName;
 
-        return PyString_FromString(result);
+        return result;
     }
     CATCH_RTI_EXCEPTION(InvalidOrderingHandle)
     CATCH_RTI_EXCEPTION(FederateNotExecutionMember)
@@ -3123,4 +3150,4 @@
     PyModule_AddObject(module, "RTIAmbassador", (PyObject 
*)&RTIAmbassadorObjectType);
 }
 
-// $Id: rtiambassador.cpp,v 1.4 2008/10/12 13:31:14 gotthardp Exp $
+// $Id: rtiambassador.cpp,v 1.5 2008/10/13 11:35:11 gotthardp Exp $




reply via email to

[Prev in Thread] Current Thread [Next in Thread]