uima-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r544559 - in /incubator/uima/uimacpp/trunk/src: cas/ cas/uima/ framework/ framework/uima/ test/src/
Date Tue, 05 Jun 2007 17:21:03 GMT
Author: eae
Date: Tue Jun  5 10:21:02 2007
New Revision: 544559

URL: http://svn.apache.org/viewvc?view=rev&rev=544559
Log:
UIMA-423 (Bhavani changes to enable leak detection and fix some leaks)

Modified:
    incubator/uima/uimacpp/trunk/src/cas/cas.cpp
    incubator/uima/uimacpp/trunk/src/cas/sofastream.cpp
    incubator/uima/uimacpp/trunk/src/cas/uima/cas.hpp
    incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp
    incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp
    incubator/uima/uimacpp/trunk/src/cas/xmideserializer_handler.cpp
    incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp
    incubator/uima/uimacpp/trunk/src/framework/cp2ucnvrt.cpp
    incubator/uima/uimacpp/trunk/src/framework/exceptions.cpp
    incubator/uima/uimacpp/trunk/src/framework/resmgr.cpp
    incubator/uima/uimacpp/trunk/src/framework/u2cpcnvrt.cpp
    incubator/uima/uimacpp/trunk/src/framework/uima/cp2ucnvrt.hpp
    incubator/uima/uimacpp/trunk/src/framework/uima/pragmas.hpp
    incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp
    incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp
    incubator/uima/uimacpp/trunk/src/test/src/test_sofa.cpp
    incubator/uima/uimacpp/trunk/src/test/src/test_xcasdeserialization.cpp
    incubator/uima/uimacpp/trunk/src/test/src/test_xmideserialization.cpp

Modified: incubator/uima/uimacpp/trunk/src/cas/cas.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/cas.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/cas.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/cas.cpp Tue Jun  5 10:21:02 2007
@@ -286,41 +286,55 @@
     isbaseCas = true;
     iv_baseCas = this;
     bOwnsCASDefinition=ownsCasDef;
+    isDeletingViews = false;
   }
 
   CAS::~CAS() {
-    if (iv_indexRepository != NULL) {
+    
+    //always delete index repository
+    if (this->iv_indexRepository != NULL) {
       delete iv_indexRepository;
       iv_indexRepository = NULL;
-    }
-
-    if (isbaseCas) {
-      if (iv_heap != NULL) {
-        delete iv_heap;
-        iv_heap = NULL;
-      }
-      if (iv_filterBuilder != NULL) {
-        delete iv_filterBuilder;
-        iv_filterBuilder = NULL;
+		}
+    if (this->iv_cpDocument != NULL) {
+      delete this->iv_cpDocument;
+      this->iv_cpDocument = NULL;
+    }
+    //initial call to delete object
+    if (this->isbaseCas) {
+      this->iv_baseCas->isDeletingViews = true;
+      
+      if (this->iv_baseCas->iv_heap != NULL) {
+        delete this->iv_baseCas->iv_heap;
+        this->iv_baseCas->iv_heap = NULL;
+      }
+      if (iv_baseCas->iv_filterBuilder != NULL) {
+        delete iv_baseCas->iv_filterBuilder;
+        iv_baseCas->iv_filterBuilder = NULL;
+      }
+      if (this->iv_baseCas->bOwnsCASDefinition ) {
+		    if (this->iv_baseCas->iv_casDefinition != NULL) { 
+               delete this->iv_baseCas->iv_casDefinition;
+			    this->iv_baseCas->iv_casDefinition = NULL;
+		    }
       }
       map<int, CAS*>::iterator mIter;
-      // make a local copy of the map
-      map<int, CAS*> mapCopy(iv_sofa2tcasMap);
-      // now delete all CAS Views using mapCopy, as the original map will be modified during
delete
-      for ( mIter = mapCopy.begin( ); mIter != mapCopy.end( ); mIter++ ) {
+      map<int,CAS*> mapcopy(this->iv_baseCas->iv_sofa2tcasMap);
+      for ( mIter = mapcopy.begin( );
+            mIter != mapcopy.end( ); mIter++ ) {
         CAS* tcas = mIter->second;
-        delete tcas;
-      }
-      iv_sofa2tcasMap.clear( );
-      iv_sofa2indexMap.clear();
+        if ( tcas != NULL) {
+          delete tcas;
+        }
+      //this->iv_baseCas->iv_sofa2tcasMap.clear( );
+      //this->iv_baseCas->iv_sofa2indexMap.clear();
+      } 
     } else {
-      // is a view ... delete from map
-      int sofaNum = getSofaNum();
-      iv_baseCas->dropView(sofaNum);
-    }
-
-    if (bOwnsCASDefinition ) {
-      delete iv_casDefinition;
+      if (!this->iv_baseCas->isDeletingViews) {
+        dropView(this->getSofaNum());
+        this->iv_baseCas->isDeletingViews=true;
+        delete this->iv_baseCas;
+      }
     }
   }
 
@@ -573,16 +587,21 @@
 
   CAS* CAS::getView(const icu::UnicodeString & localViewName) {
     SofaID* sid;
+    bool deleteSofaID = false;
     if (0 != iv_baseCas->iv_componentInfo) {
       sid = const_cast<SofaID*> (&iv_baseCas->iv_componentInfo->mapToSofaID(localViewName));
     } else {
       sid = new SofaID();
+      deleteSofaID = true;
       sid->setSofaId(localViewName);
     }
 
     // if this resolves to the Initial View, return view(1)...
     // ... as the Sofa for this view may not exist yet
     if (0==sid->getSofaId().compare(CAS::NAME_DEFAULT_SOFA)) {
+      if (deleteSofaID) {
+        delete sid;
+      }
       return getInitialView();
     }
 
@@ -597,17 +616,22 @@
                          ErrorInfo::unrecoverable
                         );
     }
+    if (deleteSofaID) {
+      delete sid;
+    }
     return getView(as);
   }
 
   CAS* CAS::createView(icu::UnicodeString const & localViewName) {
     // map the input name
     SofaID* sid;
+    bool deleteSofaID = false;
     if (0 != iv_baseCas->iv_componentInfo) {
       sid = const_cast<SofaID*> (&iv_baseCas->iv_componentInfo->mapToSofaID(localViewName));
     } else {
       sid = new SofaID();
       sid->setSofaId(localViewName);
+      deleteSofaID = true;
     }
     // test if this is the reserved name
     if ( 0 == sid->getSofaId().compare(UnicodeString(CAS::NAME_DEFAULT_SOFA)) ) {
@@ -622,6 +646,9 @@
     }
 
     SofaFS newSofa = createSofa(sid->getSofaId(), UnicodeStringRef());
+    if (deleteSofaID) {
+      delete sid;
+    }
     return getView(newSofa);
   }
 
@@ -860,9 +887,9 @@
 
   // Drop View from sofaMap
   void CAS::dropView(int sofaNum) {
-    map<int, CAS*>::iterator cit = iv_sofa2tcasMap.find(sofaNum);
-    if (cit != iv_sofa2tcasMap.end()) {
-      iv_sofa2tcasMap.erase(cit);
+    map<int, CAS*>::iterator cit = iv_baseCas->iv_sofa2tcasMap.find(sofaNum);
+    if (cit != iv_baseCas->iv_sofa2tcasMap.end()) {
+      iv_baseCas->iv_sofa2tcasMap.erase(cit);
     }
   }
 
@@ -1703,6 +1730,7 @@
 }
 
 /* ----------------------------------------------------------------------- */
+
 
 
 

Modified: incubator/uima/uimacpp/trunk/src/cas/sofastream.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/sofastream.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/sofastream.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/sofastream.cpp Tue Jun  5 10:21:02 2007
@@ -63,7 +63,11 @@
 
   //Destructor
   RemoteSofaDataStream::~RemoteSofaDataStream() {
-
+    if (iv_pHandler != NULL) {
+      iv_pHandler->closeStream();
+      delete iv_pHandler;
+      iv_pHandler = NULL;
+    }
     if (iv_pHandlerDll != NULL) {
       delete iv_pHandlerDll;
       iv_pHandlerDll=NULL;

Modified: incubator/uima/uimacpp/trunk/src/cas/uima/cas.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/cas.hpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/cas.hpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/cas.hpp Tue Jun  5 10:21:02 2007
@@ -229,6 +229,7 @@
     CAS* iv_initialView;
     bool isbaseCas;
     bool initialSofaCreated;
+    bool isDeletingViews;  //set this flag to true when destroying CAS
     AnnotatorContext *iv_componentInfo;
 
     uima::lowlevel::TyFSType     iv_utDocumentType;
@@ -1493,5 +1494,6 @@
 }
 
 #endif
+
 
 

Modified: incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp Tue Jun  5 10:21:02 2007
@@ -68,7 +68,7 @@
 	  string shortName;
 	  string qualifiedName;
 	  XmlElementName(string ns, string sname, string qname) :
-		nsUri(ns), shortName(sname), qualifiedName(qname) {}
+    nsUri(ns), shortName(sname), qualifiedName(qname) {}
   };
 
 /**
@@ -225,6 +225,21 @@
           }
         }
       }
+    }
+
+	map<int,vector<int>*>::iterator viewite;
+	for (viewite = ootsViewMembers.begin(); 
+		viewite != ootsViewMembers.end();viewite++) {
+		if (viewite->second != NULL) {
+			delete viewite->second;
+		}
+    }
+	map<int, OotsElementData*>::iterator featite;
+	for (featite = ootsFeatures.begin(); 
+		featite != ootsFeatures.end();featite++) {
+		if (featite->second != NULL) {
+			delete featite->second;
+		}
     }
   }
 

Modified: incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp Tue Jun  5 10:21:02 2007
@@ -119,6 +119,9 @@
       errInfo.setMessage(msg);
       errInfo.setSeverity(ErrorInfo::unrecoverable);
       ExcIllFormedInputError exc(errInfo);
+      delete contentHandler;
+      delete errorHandler;
+      delete parser;
       throw exc;
     }
     catch (const SAXParseException& e) {
@@ -135,6 +138,46 @@
       errInfo.setMessage(msg);
       errInfo.setSeverity(ErrorInfo::unrecoverable);
       ExcIllFormedInputError exc(errInfo);
+      delete contentHandler;
+      delete errorHandler;
+      delete parser; 
+      throw exc;
+    } catch (Exception e) {
+       ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam( e.asString() );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      delete contentHandler;
+      delete errorHandler;
+      delete parser;
+      throw exc;
+
+    } catch (...) {
+       ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam("Unknown Exception when parsing XMI document." );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      if (contentHandler != NULL) {
+        delete contentHandler;
+      }
+      if (errorHandler !=NULL) {
+        delete errorHandler;
+      }
+      if (parser != NULL) {
+        delete parser;
+      }
       throw exc;
     }
 
@@ -178,6 +221,9 @@
       errInfo.setMessage(msg);
       errInfo.setSeverity(ErrorInfo::unrecoverable);
       ExcIllFormedInputError exc(errInfo);
+      delete contentHandler;
+    delete errorHandler;
+    delete parser;
       throw exc;
     }
     catch (const SAXParseException& e) {
@@ -194,9 +240,50 @@
       errInfo.setMessage(msg);
       errInfo.setSeverity(ErrorInfo::unrecoverable);
       ExcIllFormedInputError exc(errInfo);
+      delete contentHandler;
+    delete errorHandler;
+    delete parser;
+      throw exc;
+    }  catch (Exception e) {
+       ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam( e.asString() );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      delete contentHandler;
+      delete errorHandler;
+      delete parser;
+      throw exc;
+
+    } catch (...) {
+       ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam("Unknown Exception when parsing XMI document." );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      if (contentHandler != NULL) {
+        delete contentHandler;
+      }
+      if (errorHandler !=NULL) {
+        delete errorHandler;
+      }
+      if (parser != NULL) {
+        delete parser;
+      }
       throw exc;
     }
 
+
     // Delete the parser instance and handlers
     delete contentHandler;
     delete errorHandler;
@@ -221,6 +308,7 @@
     XmiDeserializer::deserialize(fileIS, cas, sharedData);
   }
 }
+
 
 
 

Modified: incubator/uima/uimacpp/trunk/src/cas/xmideserializer_handler.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/xmideserializer_handler.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/xmideserializer_handler.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/xmideserializer_handler.cpp Tue Jun  5 10:21:02 2007
@@ -185,6 +185,13 @@
 			//readFS(typeName, attrs);
 			readFS(unsuri, ulocalname, qualifiedName, attrs);
 
+			map<UnicodeString, vector<UnicodeString>*>::iterator mite;
+            for (mite=multiValuedFeatures.begin();
+				mite != multiValuedFeatures.end(); mite++) {
+					if (mite->second != NULL) {
+						delete mite->second;
+					}
+			}
 			multiValuedFeatures.clear();
 			iv_state = FEAT_STATE;
 			break;	   
@@ -570,7 +577,7 @@
 
 		int id = -1;
 		//       int sofaRef = -1; // 0 ==> baseCas indexRepository
-		vector<int>* sofaRef = new vector<int>;
+		////vector<int>* sofaRef = new vector<int>;
 		UnicodeString attrName;
 		UnicodeString attrValue;
 		bool nameMapping = false;
@@ -1397,5 +1404,6 @@
 
 
 } // namespace uima
+
 
 

Modified: incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp Tue Jun  5 10:21:02 2007
@@ -475,7 +475,7 @@
           //printf ("itoahexadecimal: %d %d\n",i, arrayfs.get(i));
           str << out[0] << out[1];			  
         }		  
-		
+		    delete out;
         break;
                                          }
       case internal::gs_tyShortArrayType: {
@@ -1239,6 +1239,7 @@
 
 
 /* ----------------------------------------------------------------------- */
+
 
 
 

Modified: incubator/uima/uimacpp/trunk/src/framework/cp2ucnvrt.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/cp2ucnvrt.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/cp2ucnvrt.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/framework/cp2ucnvrt.cpp Tue Jun  5 10:21:02 2007
@@ -83,7 +83,10 @@
 
 
 
-
+  CodePage2UnicodeConverter::~CodePage2UnicodeConverter( )
+  {
+      ucnv_close(iv_uconverter) ;
+  }
 
   size_t CodePage2UnicodeConverter::convertBytes(UChar * pclTarget,
       size_t uiTargetMaxSize,

Modified: incubator/uima/uimacpp/trunk/src/framework/exceptions.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/exceptions.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/exceptions.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/framework/exceptions.cpp Tue Jun  5 10:21:02 2007
@@ -326,8 +326,13 @@
       }
     }
     //cout << buf << endl;
-    return string(buf);
-
+   string target(buf);
+   delete[] buf ;
+   return target;
+	 //string target;
+	 //target.assign(buf, UIMA_MSG_MAX_STR_LEN);                   // Copy the result to the
string
+   //delete buf;
+	 //return target;
   }
 
   ostream &

Modified: incubator/uima/uimacpp/trunk/src/framework/resmgr.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/resmgr.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/resmgr.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/framework/resmgr.cpp Tue Jun  5 10:21:02 2007
@@ -45,6 +45,17 @@
 #include <locale>
 #endif
 
+#if defined(_MSC_VER)
+int rc = _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+// Send all reports to STDOUT
+int rc1 =   _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
+_HFILE h1 =  _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
+int rc3 =   _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
+_HFILE h2 = _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
+int rc5 =   _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
+_HFILE h3 = _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
+#endif
+
 #include <jni.h>
 #include "uima/envvar.hpp"
 #include "uima/trace.hpp"
@@ -111,6 +122,7 @@
   /* ----------------------------------------------------------------------- */
   /*       Globals                                                           */
   /* ----------------------------------------------------------------------- */
+  
 
   ResourceManager * ResourceManager::cv_pclSingletonInstance = 0;
   TyProcedure               iv_traceProc;
@@ -146,6 +158,7 @@
       iv_useJavaLogging(false)
       /* ----------------------------------------------------------------------- */
   {
+    
     string                    str;
     const TCHAR *              cpszLogFile = 0;
 
@@ -711,7 +724,9 @@
 
       // Terminate apr (undo matching apr_initialize)
       apr_terminate();
-
+#if !defined( NDEBUG ) && defined(_MSC_VER) && defined(_CRTDBG_MAP_ALLOC)
  
+      int iRetVal = _CrtDumpMemoryLeaks();
+#endif
       UIMA_TPRINT("ResMgr instance deleted");
     }
     assert( cv_pclSingletonInstance == 0 );
@@ -984,5 +999,6 @@
 }
 
 /* <EOF> */
+
 
 

Modified: incubator/uima/uimacpp/trunk/src/framework/u2cpcnvrt.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/u2cpcnvrt.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/u2cpcnvrt.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/framework/u2cpcnvrt.cpp Tue Jun  5 10:21:02 2007
@@ -84,6 +84,9 @@
     assert(iv_uconverter != NULL);
   }
 
+  Unicode2CodePageConverter::~Unicode2CodePageConverter( ) {
+     ucnv_close(iv_uconverter) ;
+  }
   size_t Unicode2CodePageConverter::getMaximumSize(const UChar * cpclSource,
       size_t uiSourceLength) {
     size_t                     uiTargetSize;
@@ -138,4 +141,5 @@
 }
 
 /* <EOF> */
+
 

Modified: incubator/uima/uimacpp/trunk/src/framework/uima/cp2ucnvrt.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/uima/cp2ucnvrt.hpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/uima/cp2ucnvrt.hpp (original)
+++ incubator/uima/uimacpp/trunk/src/framework/uima/cp2ucnvrt.hpp Tue Jun  5 10:21:02 2007
@@ -73,6 +73,7 @@
     /** Create an instance for a converter from CCSID <TT>crclCCSID</TT> to
         CCSID CCSID::EnCCSID_UCS2. */
     CodePage2UnicodeConverter(const char * crConverterName);
+    ~CodePage2UnicodeConverter();
 
     /** TODO: fix
      * implementation of convertBytes is probably wrong.
@@ -131,4 +132,5 @@
 #endif /* UIMA_CP2UCNVRT_HPP */
 
 /* <EOF> */
+
 

Modified: incubator/uima/uimacpp/trunk/src/framework/uima/pragmas.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/uima/pragmas.hpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/uima/pragmas.hpp (original)
+++ incubator/uima/uimacpp/trunk/src/framework/uima/pragmas.hpp Tue Jun  5 10:21:02 2007
@@ -56,16 +56,17 @@
 #  pragma warning( disable: 4800 ) // forcing value to bool 'true' or 'false' (performance
warning)
 
 // special includes to get line information in memory leak output
-#  if !defined( NDEBUG ) && !defined(UIMA_NO_MAP_ALLOC)
+#if !defined( NDEBUG ) && !defined(UIMA_NO_MAP_ALLOC)
 //       Can't have _CRTDBG_MAP_ALLOC defined as it redefines malloc et al in
 //       crtdbg.h BEFORE they are declared in malloc.h (which APR drags in)
 //       malloc.h should have a matching ifndef _CRTDBG_MAP_ALLOC around the dcls
-#        ifdef CRTDBG_BUG_FIXED
-#   define _CRTDBG_MAP_ALLOC
-#   include <stdlib.h>
-#   include <crtdbg.h>
-#        endif
-#  endif
+//#        ifdef CRTDBG_BUG_FIXED
+// Appears to be fixed in VC++ 8 
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+//#endif
+#endif
 
 #elif defined(__BORLANDC__)
 #pragma warn -inl
@@ -79,4 +80,5 @@
 #endif /* UIMA_PRAGMAS_HPP */
 
 /* <EOF> */
+
 

Modified: incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp (original)
+++ incubator/uima/uimacpp/trunk/src/framework/uima/u2cpcnvrt.hpp Tue Jun  5 10:21:02 2007
@@ -71,6 +71,7 @@
     /** @name Constructors */
     /*@{*/
     Unicode2CodePageConverter(const char * converterName);
+    ~Unicode2CodePageConverter();
     /*@}*/
     /** @name Miscellaneous */
     /*@{*/
@@ -113,4 +114,5 @@
 #endif /* UIMA_U2CPCNVRT_HPP */
 
 /* <EOF> */
+
 

Modified: incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp Tue Jun  5 10:21:02
2007
@@ -377,7 +377,7 @@
 {
   LOG("UIMATEST_PRIMITIVETYPES started");
   int iRetVal = 0;
-
+  ////iRetVal = _CrtSetBreakAlloc(486);
   try {
     char const * config =
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -561,7 +561,7 @@
     //LOG("deserialize data");
     deserializer.deserializeData(serializedCas, *trgCas);
     validateFS(*trgCas);
-
+    delete ts;
     delete cas;
     delete trgCas;
     LOG("UIMATEST_PRIMITIVETYPES finished");
@@ -574,6 +574,8 @@
     cerr << "Unexpected exception " << endl;
     iRetVal = 1;
   }
+#else
+  ResourceManager::deleteInstance();
 #endif
   return iRetVal;
 }

Modified: incubator/uima/uimacpp/trunk/src/test/src/test_sofa.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/test_sofa.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/test_sofa.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/test/src/test_sofa.cpp Tue Jun  5 10:21:02 2007
@@ -50,7 +50,7 @@
 {
   LOG("UIMATEST_SOFATEST started");
   int iRetVal = 0;
-
+  //iRetVal = _CrtSetBreakAlloc(824);
   try {
     char const * config =
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -92,7 +92,7 @@
     ASSERT_OR_THROWEXCEPTION(es.isValid());
     // Initial View is #1!!!
     ASSERT_OR_THROWEXCEPTION(2 == es.getSofaRef());
-
+    delete id;
     // Set the document text
 //TODO?   es.setLocalSofaData("this beer is good");
     es.setLocalSofaData(UnicodeString("this beer is good"));
@@ -286,7 +286,6 @@
     engAnnot = (AnnotationFS)mrIt.get();
     ASSERT_OR_THROWEXCEPTION(0==engAnnot.getCoveredText().compare("this"));
 
-
     // --------------------------------------------------------
     // Test reuse of views with createSofa
     // --------------------------------------------------------
@@ -303,7 +302,7 @@
     SofaFS tv = cas->createSofa(*nuid, "text");
 	testView = cas->getView(tv);
     ASSERT_OR_THROWEXCEPTION(0 == testView->getViewName().compare("testView"));
-
+    delete nuid;
 
     // --------------------------------------------------------
     // Test sofa data stream
@@ -454,7 +453,9 @@
     }
     delete pStream;
 
+    delete ts;
     delete cas;
+    
     LOG("UIMATEST_SOFATEST finished");
   } catch (Exception & exc) {
     cerr << exc.asString() << endl;
@@ -465,6 +466,8 @@
     cerr << "Unexpected exception " << endl;
     iRetVal = 1;
   }
+#else
+  ResourceManager::deleteInstance();
 #endif
   return iRetVal;
 }

Modified: incubator/uima/uimacpp/trunk/src/test/src/test_xcasdeserialization.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/test_xcasdeserialization.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/test_xcasdeserialization.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/test/src/test_xcasdeserialization.cpp Tue Jun  5 10:21:02
2007
@@ -26,6 +26,7 @@
 #include "uima/xmlwriter.hpp"
 #include "uima/xcasdeserializer.hpp"
 #include "uima/casdefinition.hpp"
+#include "uima/xmiwriter.hpp"
 
 #include <fstream>
 
@@ -49,7 +50,7 @@
 {
   LOG("UIMATEST_XCASSERIALIZATION started");
   int iRetVal = 0;
-
+  //iRetVal = _CrtSetBreakAlloc(824);
   try {
 
     ResourceManager::createInstance("test");
@@ -124,7 +125,7 @@
     // Deserialize XCAS
     cas->reset();
     XCASDeserializer::deserialize("temp.xcas", *cas);
-
+    
     //TODO compare!
 
 
@@ -168,7 +169,7 @@
 
 
 
-
+    delete  casDef;
     delete cas;
     delete v1cas;
     LOG("UIMATEST_XCASSERIALIZATION finished");
@@ -180,7 +181,9 @@
     cerr << "Unexpected exception " << endl;
     iRetVal = 1;
   }
-
+#ifndef NDEBUG
+  ResourceManager::deleteInstance();
+#endif 
   return iRetVal;
 }
 

Modified: incubator/uima/uimacpp/trunk/src/test/src/test_xmideserialization.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/test_xmideserialization.cpp?view=diff&rev=544559&r1=544558&r2=544559
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/test_xmideserialization.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/test/src/test_xmideserialization.cpp Tue Jun  5 10:21:02
2007
@@ -22,6 +22,15 @@
 /* ----------------------------------------------------------------------- */
 /*       Include dependencies                                              */
 /* ----------------------------------------------------------------------- */
+
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+
+///#define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__)
+
+
+
 #include "uima/api.hpp"
 #include "uima/xmiwriter.hpp"
 #include "uima/xmideserializer.hpp"
@@ -31,7 +40,7 @@
 
 #include <fstream>
 
-#ifndef NDEBUG
+#ifdef NDEBUG
 #define ASSERT_OR_THROWEXCEPTION(x) assert(x)
 #else
 #define ASSERT_OR_THROWEXCEPTION(x) if (!(x)) { cerr << __FILE__ << ": Error
in line " << __LINE__ << endl; exit(1); }
@@ -249,12 +258,13 @@
     outputStream.open("temp.xmi");
     ASSERT_OR_THROWEXCEPTION(outputStream.is_open());
 
-    XmiWriter writer(*cas,false);
+    XmiWriter writer(*cas,true);
     writer.write(outputStream);
     outputStream.close();
 
     ostringstream str;
-    writer.write(str);
+    XmiWriter writerstr(*cas,true);
+    writerstr.write(str);
     str.flush();
 
     // deserialize into another CAS (repeat twice to check it still works after reset)
@@ -308,11 +318,12 @@
 
   //reserialize cas1
   stringstream str1;
-  writer.write(str1);
-
+  XmiWriter writerstr1(*cas1, false);
+  writerstr1.write(str1);
+  
   //reserialize cas2
   stringstream str2;
-  XmiWriter writer2(*cas2,false);
+  XmiWriter writer2(*cas2,true);
   writer2.write(str2);
 
   //compare serialized xmi string
@@ -470,15 +481,18 @@
 ---------------------------------- */
 {
   LOG("UIMATEST_XMISERIALIZATION started");
+
   int iRetVal = 0;
 
+//#if !defined(NDEBUG) && defined(_MSC_VER)
+//   iRetVal = _CrtSetBreakAlloc(662909);
+//#endif
   try {
 
     ResourceManager::createInstance("testxmi");
     ofstream outputStream;
     ErrorInfo errorInfo;
 
-	
     TextAnalysisEngineSpecifierBuilder builder;
 	
 	  //setup
@@ -486,7 +500,7 @@
     UnicodeString tsfn = ResourceManager::resolveFilename(tsFile, tsFile);
     TypeSystem * ts = Framework::createTypeSystem( ((UnicodeStringRef)tsfn).asUTF8().c_str(),errorInfo);
     ASSERT_OR_THROWEXCEPTION( EXISTS(ts) );
-
+	
 	  UnicodeString tsFile2("ExampleCas/testTypeSystem_withMultiRefs.xml");
     UnicodeString tsfn2 = ResourceManager::resolveFilename(tsFile2, tsFile2);
     TypeSystem * ts2 = Framework::createTypeSystem( ((UnicodeStringRef)tsfn2).asUTF8().c_str(),errorInfo);
@@ -529,6 +543,7 @@
 	  testMultipleSofas(casDef);
 	  LOG("UIMACPP_XMITEST testMultipleSofas Finished");
 
+    
 	  //test OOTS Missing Type 1
 	  TypeSystemDescription * baseTSDesc = new TypeSystemDescription();
 	  TypeSystem * baseTS = Framework::createTypeSystem(*baseTSDesc,"base",errorInfo);
@@ -547,6 +562,7 @@
     testOotsNewPrimitives(baseCasDef, primitivesCasDef, ((UnicodeStringRef)newpxcasfn).asUTF8().c_str());
      LOG("UIMACPP_XMITEST OOTS new primitives missing type Finished");
 
+
     //test OOTS missing feature
 	  LOG("UIMACPP_XMITEST OOTS new primitives missing feature Start");
 	  UnicodeString newpPartialFile("ExampleCas/newprimitivesPartialTypeSystem.xml");
@@ -559,7 +575,7 @@
 	  delete newpPartialts;
 	  delete newpPartialCasDef;
 	  LOG("UIMACPP_XMITEST OOTS new primitives missing features Finished");
-	
+
 	  //test OOTS complex cas missing types
 	  LOG("UIMACPP_XMITEST OOTS Complex CAS Missing Types Start");
 	  testOotsComplexCas(baseCasDef, casDef, "ExampleCas/cas.xml");
@@ -588,7 +604,7 @@
  			XmiDeserializer::deserialize(xmlfn, *pCas);
  		} catch (Exception e)  {
  			LOG("Exception thrown correctly: ");
- 			LOG(e.asString());
+ 			//LOG(e.asString());
  			bExceptionThrown =true;
  		}
  	  ASSERT_OR_THROWEXCEPTION(bExceptionThrown); 
@@ -597,16 +613,21 @@
 		
     delete partialts;
     delete partialTSCasDef;
-	  delete primitivests;
+    delete primitivests;
 	  delete primitivesCasDef;
-	  delete casDef;
     delete baseTSDesc;
 	  delete baseTS;
 	  delete baseCasDef;
-		
-
+    
+		delete casDef;
+    delete ts;
+		delete ts2;
+    for (int i=0; i < fsDesc.size();i++) {
+      delete fsDesc.at(i);
+    }
+    
     LOG("UIMATEST_XMISERIALIZATION finished");
-
+  
   } catch (Exception & exc) {
     cerr << exc.asString() << endl;
     iRetVal = 1;
@@ -614,7 +635,6 @@
     cerr << "Unexpected exception " << endl;
     iRetVal = 1;
   }
-
   return iRetVal;
 }
 



Mime
View raw message