tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gw...@apache.org
Subject svn commit: r510021 - in /incubator/tuscany/cpp/sdo/runtime/core: src/commonj/sdo/SAX2Parser.cpp test/ test/sdotest.cpp test/sdotest2.cpp
Date Wed, 21 Feb 2007 14:28:07 GMT
Author: gwinn
Date: Wed Feb 21 06:28:06 2007
New Revision: 510021

URL: http://svn.apache.org/viewvc?view=rev&rev=510021
Log:
Fixes identified by valgrind.

Modified:
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SAX2Parser.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/   (props changed)
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SAX2Parser.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SAX2Parser.cpp?view=diff&rev=510021&r1=510020&r2=510021
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SAX2Parser.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SAX2Parser.cpp Wed Feb 21 06:28:06
2007
@@ -308,8 +308,10 @@
         SAX2Parser::~SAX2Parser()
         {
             // xmlCleanupParser();
-            if (currentFile != 0)delete currentFile;
-            
+           if (currentFile != 0)
+           {
+              delete[] currentFile;
+           }
         }
         
         const char* SAX2Parser::getCurrentFile() const
@@ -322,7 +324,7 @@
         {
             if (currentFile != 0)
             {
-                delete currentFile;
+                delete[] currentFile;
             }
             currentFile = new char[strlen(filename)+1];
             strcpy(currentFile,filename);
@@ -336,7 +338,7 @@
 
             if (currentFile != 0)
             {
-                delete currentFile;
+                delete[] currentFile;
             }
             currentFile = new char[strlen(filename)+1];
             strcpy(currentFile,filename);

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Feb 21 06:28:06 2007
@@ -56,3 +56,6 @@
 tuscany_sdo_test
 clone-testout.xml
 tuscany963.out.xml
+jira980_jungle_out.xml
+jira980_mixedJungle_out.xml
+jira980_splitJungle_out.xml

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp?view=diff&rev=510021&r1=510020&r2=510021
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp Wed Feb 21 06:28:06 2007
@@ -3073,41 +3073,54 @@
 int sdotest::jira705()
 {
 
-  char* retval = NULL;
+   char* retval = NULL;
 
-  try
-  {
-    DataFactoryPtr dataFactoryPtr = DataFactory::getDataFactory();
-    XSDHelperPtr xsdHelperPtr = HelperProvider::getXSDHelper((DataFactory *)dataFactoryPtr);
-    XMLHelperPtr xmlHelperPtr = HelperProvider::getXMLHelper((DataFactory *)dataFactoryPtr);
-    xsdHelperPtr->defineFile("jira705.xsd");
+   try
+   {
+      DataFactoryPtr dataFactoryPtr = DataFactory::getDataFactory();
+      XSDHelperPtr xsdHelperPtr = HelperProvider::getXSDHelper((DataFactory *)dataFactoryPtr);
+      XMLHelperPtr xmlHelperPtr = HelperProvider::getXMLHelper((DataFactory *)dataFactoryPtr);
+      xsdHelperPtr->defineFile("jira705.xsd");
 
-    DataObjectPtr dataObjectPtr = dataFactoryPtr->create("http://ConvertedStockQuote",
"getQuote");
+      DataObjectPtr dataObjectPtr = dataFactoryPtr->create("http://ConvertedStockQuote",
+                                                           "getQuote");
 
-    dataObjectPtr->setCString("ticker1", "IBM");
-    dataObjectPtr->setNull("ticker2");
+      dataObjectPtr->setCString("ticker1", "IBM");
+      dataObjectPtr->setNull("ticker2");
 
-    XMLDocumentPtr xmlDocumentPtr = xmlHelperPtr->createDocument(dataObjectPtr, 0, "getQuote");
+      XMLDocumentPtr xmlDocumentPtr = xmlHelperPtr->createDocument(dataObjectPtr, 0, "getQuote");
 
-    retval = xmlHelperPtr->save(xmlDocumentPtr, 2);
+      retval = xmlHelperPtr->save(xmlDocumentPtr, 2);
+   }
+   catch (SDORuntimeException e)
+   {
+      if (!silent) cout << "jira705 test failed" << endl;
+      if (retval != NULL)
+      {
+         delete[] retval;
+      }
 
-  }
-  catch (SDORuntimeException e)
-  {
-     if (!silent) cout << "jira705 test failed" << endl;
-     return 0;
-  }
+      return 0;
+   }
 
-  FILE *outfile = fopen("jira705_out.xml","w+");
+   FILE *outfile = fopen("jira705_out.xml", "w+");
    if (outfile == 0)
    {
       if (!silent) cout << "Unable to open jira705_out.xml" << endl;
+      if (retval != NULL)
+      {
+         delete[] retval;
+      }
       return 0;
    }
 
    fprintf(outfile, "%s", retval);
 
    fclose(outfile);
+   if (retval != NULL)
+   {
+      delete[] retval;
+   }
 
    return comparefiles("jira705_out.xml", "jira705_out.txt");
 

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp?view=diff&rev=510021&r1=510020&r2=510021
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Wed Feb 21 06:28:06 2007
@@ -729,156 +729,208 @@
 
 
 int sdotest::testanytwo(const char* xsd, const char* xsd2,
-                         const char* xml)
+                        const char* xml)
 {
+   unsigned int i, j;
 
+   try
+   {
+      char * name1 = new char[strlen(xsd)+5];
+      char * name2 = new char[strlen(xml)+5];
+      char * name3 = new char[strlen(xsd)+5];
+      char * name4 = new char[strlen(xml)+5];
 
-    unsigned int i,j;
+      strcpy(name1,xsd);
+      strcpy(name2,xml);
 
-    try {
+      char *c;
 
-    char * name1 = new char[strlen(xsd)+5];
-    char * name2 = new char[strlen(xml)+5];
-    char * name3 = new char[strlen(xsd)+5];
-    char * name4 = new char[strlen(xml)+5];
-    strcpy(name1,xsd);
-    strcpy(name2,xml);
-    char *c;
-    while ((c = strchr(name1,'.')) != 0)*c = '_';
-    while ((c = strchr(name2,'.')) != 0)*c = '_';
-    strcpy(name3,name1);
-    strcpy(name4,name2);
+      while ((c = strchr(name1,'.')) != 0)*c = '_';
+      while ((c = strchr(name2,'.')) != 0)*c = '_';
+
+      strcpy(name3,name1);
+      strcpy(name4,name2);
     
-    strcat(name1,".dat");
-    strcat(name2,".dat");
-    strcat(name3,".txt");
-    strcat(name4,".txt");
+      strcat(name1,".dat");
+      strcat(name2,".dat");
+      strcat(name3,".txt");
+      strcat(name4,".txt");
 
-    DataFactoryPtr mdg  = DataFactory::getDataFactory();
+      DataFactoryPtr mdg  = DataFactory::getDataFactory();
 
-    XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg);
+      XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg);
     
-    if (xsd)
-    {
-        xsh->defineFile(xsd);
+      if (xsd)
+      {
+         xsh->defineFile(xsd);
 
-        if ((i = xsh->getErrorCount()) > 0)
-        {
+         if ((i = xsh->getErrorCount()) > 0)
+         {
             if (!silent)
             {
-                cout << "PROBLEM: Testany XSD reported some errors:" << endl;
-                for (j=0;j<i;j++)
-                {
-                    const char *m = xsh->getErrorMessage(j);
-                    if (m != 0) cout << m;
-                    cout << endl;
-                }
+               cout << "PROBLEM: Testany XSD reported some errors:" << endl;
+               for (j=0;j<i;j++)
+               {
+                  const char *m = xsh->getErrorMessage(j);
+                  if (m != 0) cout << m;
+                  cout << endl;
+               }
             }
+            delete[] name1;
+            delete[] name2;
+            delete[] name3;
+            delete[] name4;
+            
             return 0;
-        }
+         }
 
-    }
+      }
 
-    if (xsd2)
-    {
-        xsh->defineFile(xsd2);
+      if (xsd2)
+      {
+         xsh->defineFile(xsd2);
 
-        if ((i = xsh->getErrorCount()) > 0)
-        {
+         if ((i = xsh->getErrorCount()) > 0)
+         {
             if (!silent)
             {
-                cout << "PROBLEM: Testany XSD2 reported some errors:" << endl;
-                for (j=0;j<i;j++)
-                {
-                    const char *m = xsh->getErrorMessage(j);
-                    if (m != 0) cout << m;
-                    cout << endl;
-                }
+               cout << "PROBLEM: Testany XSD2 reported some errors:" << endl;
+               for (j=0;j<i;j++)
+               {
+                  const char *m = xsh->getErrorMessage(j);
+                  if (m != 0) cout << m;
+                  cout << endl;
+               }
             }
+
+            delete[] name1;
+            delete[] name2;
+            delete[] name3;
+            delete[] name4;
+
             return 0;
-        }
-    }
+         }
+      }
 
-    if (xsd)
-    {
+      if (xsd)
+      {
 
 
-        FILE *f1 = fopen(name1,"w+");
-        if (f1 == 0)
-        {
+         FILE *f1 = fopen(name1,"w+");
+         if (f1 == 0)
+         {
             if (!silent)cout << "Unable to open " << name1 << endl;
+
+            delete[] name1;
+            delete[] name2;
+            delete[] name3;
+            delete[] name4;
+
             return 0;
-        }
+         }
 
-        TypeList tl = mdg->getTypes();
+         TypeList tl = mdg->getTypes();
 
-        fprintf(f1,"***** TESTANY ******************************************\n");
+         fprintf(f1,"***** TESTANY ******************************************\n");
 
-        for (i=0;i<tl.size();i++)
-        {
+         for (i=0;i<tl.size();i++)
+         {
             fprintf(f1,"Type:%s#%s\n",tl[i].getURI(),tl[i].getName());
             PropertyList pl = tl[i].getProperties();
             for (unsigned int j=0;j<pl.size();j++)
             {
-                fprintf(f1,"Property:%s ",pl[j].getName());
-                if (pl[j].isMany())
-                     fprintf(f1, "(many) ");
-                fprintf(f1,  " of type %s\n",pl[j].getType().getName());
+               fprintf(f1,"Property:%s ",pl[j].getName());
+               if (pl[j].isMany())
+                  fprintf(f1, "(many) ");
+               fprintf(f1,  " of type %s\n",pl[j].getType().getName());
             }
-        }
+         }
 
-        fprintf(f1,"*******************************END TYPES******************\n");
+         fprintf(f1,"*******************************END TYPES******************\n");
     
-        fclose(f1);
+         fclose(f1);
 
-        if (!comparefiles(name1,name3)) return 0;
+         if (!comparefiles(name1,name3))
+         {
+            delete[] name1;
+            delete[] name2;
+            delete[] name3;
+            delete[] name4;
 
-    }
+            return 0;
+         }
+      }
     
 
-    if (xml == 0 || strlen(xml) == 0) return 1;
+      if (xml == 0 || strlen(xml) == 0)
+      {
+         delete[] name1;
+         delete[] name2;
+         delete[] name3;
+         delete[] name4;
+
+         return 1;
+      }
+
+      FILE *f2 = fopen(name2,"w+");
+      if (f2 == 0)
+      {
+         if (!silent)cout << "Unable to open " << name2 << endl;
+         delete[] name1;
+         delete[] name2;
+         delete[] name3;
+         delete[] name4;
 
+         return 0;
+      }
 
-    FILE *f2 = fopen(name2,"w+");
-    if (f2 == 0)
-    {
-        if (!silent)cout << "Unable to open " << name2 << endl;
-        return 0;
-    }
-
-    XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg);
+      XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg);
  
-    XMLDocumentPtr doc = xmh->loadFile(xml);
+      XMLDocumentPtr doc = xmh->loadFile(xml);
 
-    if ((i = xmh->getErrorCount()) > 0)
-    {
-        if (!silent)
-        {
+      if ((i = xmh->getErrorCount()) > 0)
+      {
+         if (!silent)
+         {
             cout << "TestAny XML found errors:" << endl;
             for (j=0;j<i;j++)
             {
-                const char *m = xmh->getErrorMessage(j);
-                if (m != 0) cout << m;
-                cout << endl;
+               const char *m = xmh->getErrorMessage(j);
+               if (m != 0) cout << m;
+               cout << endl;
             }
-        }
-        return 0;
-    }
-    else 
-    {
-        DataObjectPtr dob = doc->getRootDataObject();
-        printDataObject(f2, dob);
-    }
-
-    fclose(f2);
-    return comparefiles(name2,name4);
-
-    }
-    catch (SDORuntimeException e)
-    {
-        if (!silent)cout << "Exception in TestAnyTwo" << e << endl;
-        return 0;
-    }
+         }
+         delete[] name1;
+         delete[] name2;
+         delete[] name3;
+         delete[] name4;
+
+         return 0;
+      }
+      else 
+      {
+         DataObjectPtr dob = doc->getRootDataObject();
+         printDataObject(f2, dob);
+      }
+
+      fclose(f2);
+      int result = comparefiles(name2,name4);
+
+      delete[] name1;
+      delete[] name2;
+      delete[] name3;
+      delete[] name4;
+
+      return result;
+    
+
+   }
+   catch (SDORuntimeException e)
+   {
+      if (!silent)cout << "Exception in TestAnyTwo" << e << endl;
+
+      return 0;
+   }
 }
 
 int sdotest::openseq()



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message