You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2005/07/04 09:51:15 UTC
cvs commit: ws-axis/c/samples/client/base Client.cpp
samisa 2005/07/04 00:51:15
Modified: c/samples/client/base Client.cpp
Log:
fixed some client level memory leaks
Revision Changes Path
1.6 +36 -8 ws-axis/c/samples/client/base/Client.cpp
Index: Client.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/samples/client/base/Client.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Client.cpp 31 May 2005 05:04:17 -0000 1.5
+++ Client.cpp 4 Jul 2005 07:51:15 -0000 1.6
@@ -76,12 +76,15 @@
strcpy (buffer1, bigstring.c_str ());
ws.setTransportProperty ("SOAPAction", "InteropBase#echoString");
- printf (ws.echoString (buffer1));
- if (0 == strcmp (ws.echoString ("hello world"), "hello world"))
+
+ char* cpResult = ws.echoString ("hello world");
+ if (0 == strcmp (cpResult, "hello world"))
printf ("successful\n");
else
printf ("failed\n");
+ delete [] cpResult;
+
// testing echoStringArray
xsd__string_Array arrstr;
arrstr.m_Array = new char *[ARRAYSIZE];
@@ -95,11 +98,17 @@
ws.setTransportProperty ("SOAPAction",
"InteropBase#echoStringArray");
printf ("invoking echoStringArray...\n");
- if (ws.echoStringArray (arrstr).m_Array != NULL)
+
+ char** arrstrResult = ws.echoStringArray (arrstr).m_Array;
+
+ if (arrstrResult != NULL)
printf ("successful\n");
else
printf ("failed\n");
+ delete [] arrstr.m_Array;
+ delete [] arrstrResult;
+
// testing echoInteger
ws.setTransportProperty ("SOAPAction", "InteropBase#echoInteger");
printf ("invoking echoInteger...\n");
@@ -127,6 +136,8 @@
else
printf ("failed\n");
+ delete [] arrint.m_Array;
+
// testing echoFloat
printf ("invoking echoFloat...\n");
float fvalue = 1.4214;
@@ -154,6 +165,8 @@
else
printf ("failed\n");
+ delete [] arrfloat.m_Array;
+
// testing echo Struct
SOAPStruct stct;
xsd__int integer = 5000;
@@ -168,6 +181,8 @@
else
printf ("failed\n");
+ free(stct.varString);
+
//testing echo Array of Struct
SOAPStruct_Array arrstct;
arrstct.m_Array = new SOAPStruct[ARRAYSIZE];
@@ -187,11 +202,17 @@
ws.setTransportProperty ("SOAPAction",
"InteropBase#echoStructArray");
printf ("invoking echoStructArray...\n");
- if (ws.echoStructArray (arrstct).m_Array != NULL)
+ SOAPStruct_Array arrstctResult = ws.echoStructArray (arrstct);
+ if (arrstctResult.m_Array != NULL)
printf ("successful\n");
else
printf ("failed\n");
+ delete [] arrstct.m_Array;
+ for( x = 0; x < arrstctResult.m_Size; x++)
+ delete [] arrstctResult.m_Array[x].varString;
+ delete [] arrstctResult.m_Array;
+
//testing echo void
printf ("invoking echoVoid...\n");
ws.setTransportProperty ("SOAPAction", "InteropBase#echoVoid");
@@ -207,13 +228,17 @@
bb.__ptr = (unsigned char *) strdup (bstr);
bb.__size = strlen (bstr);
ws.setTransportProperty ("SOAPAction", "InteropBase#echoBase64");
- if (bb.__size == ws.echoBase64 (bb).__size)
+ xsd__base64Binary bbResult = ws.echoBase64 (bb);
+ if (bb.__size == bbResult.__size)
{
printf ("successful\n");
- printf ("Returned String :\n%s\n", bb.__ptr);
+ printf ("Returned String :\n%s\n", bbResult.__ptr);
}
else
printf ("failed\n");
+
+ free(bb.__ptr);
+ delete [] bbResult.__ptr;
time_t tim;
time (&tim);
@@ -232,14 +257,17 @@
hb.__size = strlen (bstr);
ws.setTransportProperty ("SOAPAction",
"InteropBase#echoHexBinary");
- if (hb.__size == ws.echoHexBinary (hb).__size)
+ xsd__hexBinary hbReturn = ws.echoHexBinary (hb);
+ if (hb.__size == hbReturn.__size)
{
printf ("successful\n");
- printf ("Returned String :\n%s\n", hb.__ptr);
+ printf ("Returned String :\n%s\n", hbReturn.__ptr);
}
else
printf ("failed\n");
+ free(hb.__ptr);
+ delete [] hbReturn.__ptr;
//testing echo decimal
printf ("invoking echoDecimal...\n");
ws.setTransportProperty ("SOAPAction", "InteropBase#echoDecimal");