You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by pr...@apache.org on 2005/11/03 18:07:31 UTC

svn commit: r330581 - in /webservices/axis/trunk/c: include/axis/Axis.hpp include/axis/AxisUserAPI.hpp src/cbindings/AxisC.cpp src/common/AxisUserAPI.cpp src/engine/Axis.cpp src/xml/xerces/XercesHandler.cpp

Author: prestonf
Date: Thu Nov  3 09:07:21 2005
New Revision: 330581

URL: http://svn.apache.org/viewcvs?rev=330581&view=rev
Log:
Part of the fix for AXISCPP-149.  This covers all of the simple types.

Modified:
    webservices/axis/trunk/c/include/axis/Axis.hpp
    webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp
    webservices/axis/trunk/c/src/cbindings/AxisC.cpp
    webservices/axis/trunk/c/src/common/AxisUserAPI.cpp
    webservices/axis/trunk/c/src/engine/Axis.cpp
    webservices/axis/trunk/c/src/xml/xerces/XercesHandler.cpp

Modified: webservices/axis/trunk/c/include/axis/Axis.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/include/axis/Axis.hpp?rev=330581&r1=330580&r2=330581&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/Axis.hpp (original)
+++ webservices/axis/trunk/c/include/axis/Axis.hpp Thu Nov  3 09:07:21 2005
@@ -25,7 +25,7 @@
 #if !defined(__AXIS_H_OF_AXIS_INCLUDED__)
 #define __AXIS_H_OF_AXIS_INCLUDED__
 
-#include <axis/GDefine.hpp>
+#include <axis/TypeMapping.hpp>
 
 AXIS_CPP_NAMESPACE_START
 
@@ -53,6 +53,15 @@
 	 * Terminates the Axis runtime.
 	 */
     static void terminate();
+    
+    /**
+     * Deletes storage allocated by the Axis engine, that is no longer required
+     * by the customer application.
+     * 
+     * @param pValue
+     * @param type The XSDTYPE of the storage item to be deleted.
+     */
+    static void AxisDelete(void* pValue, XSDTYPE type);
 };
 
 AXIS_CPP_NAMESPACE_END

Modified: webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp?rev=330581&r1=330580&r2=330581&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp (original)
+++ webservices/axis/trunk/c/include/axis/AxisUserAPI.hpp Thu Nov  3 09:07:21 2005
@@ -290,7 +290,7 @@
 class STORAGE_CLASS_INFO xsd__hexBinary {
 public:
     xsd__hexBinary();
-    ~xsd__hexBinary();
+	~xsd__hexBinary();
     xsd__unsignedByte * __ptr;
     xsd__int __size;
 };

Modified: webservices/axis/trunk/c/src/cbindings/AxisC.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/cbindings/AxisC.cpp?rev=330581&r1=330580&r2=330581&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/AxisC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/AxisC.cpp Thu Nov  3 09:07:21 2005
@@ -21,6 +21,7 @@
 extern "C" {
 #include <axis/GDefine.h>
 #include <axis/AxisUserAPI.h>
+#include <axis/TypeMapping.h>
 #include <axis/Axis.h>
 
 STORAGE_CLASS_INFO void axiscInitializeAxis(AxiscBool bIsServer) {
@@ -32,4 +33,7 @@
 }
 }
 
-
+AXISC_STORAGE_CLASS_INFO void axiscAxisDelete(void * pValue,  AXISC_XSDTYPE type)
+{
+    Axis::AxisDelete(pValue, (XSDTYPE) type);
+}

Modified: webservices/axis/trunk/c/src/common/AxisUserAPI.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/common/AxisUserAPI.cpp?rev=330581&r1=330580&r2=330581&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisUserAPI.cpp (original)
+++ webservices/axis/trunk/c/src/common/AxisUserAPI.cpp Thu Nov  3 09:07:21 2005
@@ -40,7 +40,7 @@
   __size = 0;
 }
 
-xsd__base64Binary::~xsd__base64Binary() { 
+xsd__base64Binary::~xsd__base64Binary() {
 }
 
 xsd__hexBinary::xsd__hexBinary() { 
@@ -48,7 +48,7 @@
   __size = 0;
 }
 
-xsd__hexBinary::~xsd__hexBinary() { 
+xsd__hexBinary::~xsd__hexBinary() {
 }
 
 AnyType::AnyType() { 

Modified: webservices/axis/trunk/c/src/engine/Axis.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/engine/Axis.cpp?rev=330581&r1=330580&r2=330581&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/engine/Axis.cpp (original)
+++ webservices/axis/trunk/c/src/engine/Axis.cpp Thu Nov  3 09:07:21 2005
@@ -46,6 +46,8 @@
 #include <map>
 #include <iostream>
 
+#include <axis/AxisUserAPI.hpp>
+
 #include "../soap/SoapFault.h"
 #include "../soap/URIMapping.h"
 #include "../soap/SoapKeywordMapping.h"
@@ -507,3 +509,426 @@
     uninitialize_module();
 }
 
+void Axis::AxisDelete(void *pValue, XSDTYPE type)
+{
+    switch (type)
+    {
+        case XSD_DURATION:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__duration*) pValue;
+                pValue = NULL;
+            }
+			break;
+        }
+        case XSD_DATETIME:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__dateTime*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_TIME:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__time*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_DATE:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__date*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_GYEARMONTH:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__gYearMonth*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_GYEAR:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__gYear*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_GMONTHDAY:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__gMonthDay*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_GDAY:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__gDay*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_GMONTH:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__gMonth*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_STRING:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__string) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NORMALIZEDSTRING:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__normalizedString) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_TOKEN:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__token) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_LANGUAGE:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__language) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NAME:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__Name) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NCNAME:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__NCName) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_ID:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__ID) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_IDREF:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__IDREF) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_IDREFS:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__IDREFS) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_ENTITY:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__ENTITY) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_ENTITIES:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__ENTITIES) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NMTOKEN:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__NMTOKEN) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NMTOKENS:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__NMTOKENS) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_BOOLEAN:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__boolean*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_BASE64BINARY:
+        {
+            if (pValue != NULL)
+            {
+				if(	((xsd__base64Binary*) pValue)->__ptr != NULL)
+				{
+					delete [] ((xsd__base64Binary*) pValue)->__ptr;
+					((xsd__base64Binary*) pValue)->__ptr = NULL;
+				}
+
+                delete (xsd__base64Binary*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_HEXBINARY:
+        {
+            if (pValue != NULL)
+            {
+				if(	((xsd__hexBinary*) pValue)->__ptr != NULL)
+				{
+					delete [] ((xsd__hexBinary*) pValue)->__ptr;
+					((xsd__hexBinary*) pValue)->__ptr = NULL;
+				}
+
+                delete (xsd__hexBinary*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_FLOAT:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__float*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_DECIMAL:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__decimal*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NONPOSITIVEINTEGER:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__nonPositiveInteger*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NEGATIVEINTEGER:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__negativeInteger*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_INTEGER:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__integer*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_LONG:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__long*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_INT:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__int*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_SHORT:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__short*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_BYTE:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__byte*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NONNEGATIVEINTEGER:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__nonNegativeInteger*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_UNSIGNEDLONG:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__unsignedLong*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_UNSIGNEDINT:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__unsignedInt*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_UNSIGNEDSHORT:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__unsignedShort*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_UNSIGNEDBYTE:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__unsignedByte*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_POSITIVEINTEGER:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__positiveInteger*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_DOUBLE:
+        {
+            if (pValue != NULL)
+            {
+                delete (xsd__double*) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_ANYURI:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__anyURI) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_QNAME:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__QName) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case XSD_NOTATION:
+        {
+            if (pValue != NULL)
+            {
+                delete [] (xsd__NOTATION) pValue;
+                pValue = NULL;
+            }
+         break;
+        }
+        case USER_TYPE:
+            // The USER_TYPE object should be cleared by the Application
+            break;
+        case XSD_ARRAY:
+        case XSD_ANY:
+        case ATTACHMENT:
+        case XSD_UNKNOWN:
+        default:
+			;
+    }
+}
\ No newline at end of file

Modified: webservices/axis/trunk/c/src/xml/xerces/XercesHandler.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/xml/xerces/XercesHandler.cpp?rev=330581&r1=330580&r2=330581&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/xml/xerces/XercesHandler.cpp (original)
+++ webservices/axis/trunk/c/src/xml/xerces/XercesHandler.cpp Thu Nov  3 09:07:21 2005
@@ -101,37 +101,55 @@
 void XercesHandler::characters(const XMLCh* const chars, 
                                const unsigned int length)
 {
-    const char* cp_PreviousNameOrValue = NULL;
+    const char *	cp_PreviousNameOrValue = NULL;
+
     if( m_pCurrElement && m_pCurrElement->m_pchNameOrValue)
     {
         if (m_pCurrElement->m_type == CHARACTER_ELEMENT)
+		{
             cp_PreviousNameOrValue = m_pCurrElement->m_pchNameOrValue;
+		}
     }
+
     m_pCurrElement = m_pNextElement;
     m_pNextElement->m_type = CHARACTER_ELEMENT;
-    
+
+// The following code is necessary as it is important to get the correct heap
+// (i.e the one that XMLString is using!) when creating a memory object to put
+// back into 'm_pNextElement->m_pchNameOrValue'.  By using the XMLString
+// function, we can ensure that only the memory belonging to (and thus able to
+// destroy) the same segment as XMLString is used.  If you don't understand
+// what is going on, don't change it!
     if (cp_PreviousNameOrValue)
     {
-        char* cp_CurrentNameOrValue = XMLString::transcode(chars);
-        //char* cp_FullNameOrValue  = (char*) malloc(strlen(cp_PreviousNameOrValue) + strlen(cp_CurrentNameOrValue) + 1);
-		//Chinthana:Removed malloc
-		char* cp_FullNameOrValue  = new char[strlen(cp_PreviousNameOrValue) + strlen(cp_CurrentNameOrValue) + 1];
-        //cp_FullNameOrValue[0] = '\0'; 
-		strcpy(cp_FullNameOrValue, cp_PreviousNameOrValue); 
-        strcat(cp_FullNameOrValue, cp_CurrentNameOrValue);
-        m_pNextElement->m_pchNameOrValue = (const char*)cp_FullNameOrValue;
-        //free(const_cast <char*> (cp_PreviousNameOrValue));
-        //free(cp_CurrentNameOrValue);
-		//Chinthana:Removed free
-		delete[] (const_cast <char*> (cp_PreviousNameOrValue));
-		delete[] cp_CurrentNameOrValue;
-		//16/09/2005.............................................................
+		// Get a pointer to the transcoded character.
+		char *	pTransChar = XMLString::transcode( chars);
+
+		// Create a dummy string and populate.
+		char *	psDummy = new char[ strlen( m_pNextElement->m_pchNameOrValue) +
+									strlen( pTransChar) + 1];
+		strcpy( psDummy, m_pNextElement->m_pchNameOrValue);
+		strcat( psDummy, pTransChar);
 
+		// Create pointer to new Name or Value string.
+		char *	pNewNameOrValue = XMLString::replicate( psDummy);
+
+		// Delete the old Name and Value string.
+		XMLString::release( const_cast<char**> (&(m_pCurrElement->m_pchNameOrValue)));
+
+		// Assign the new value of Name or Value string.
+		m_pNextElement->m_pchNameOrValue = pNewNameOrValue;
+
+		// Clean up.
+		delete [] psDummy;
+		XMLString::release( &pTransChar);
     }
     else
-        m_pNextElement->m_pchNameOrValue = XMLString::transcode(chars);
-    
+	{
+        m_pNextElement->m_pchNameOrValue = XMLString::transcode( chars);
+	}
 }
+
 void XercesHandler::ignorableWhitespace(const XMLCh* const chars, 
                                         const unsigned int length)
 {}