predictivesearch/PcsAlgorithm/Algorithm2/src/FindUtilChineseECE.cpp
branchRCL_3
changeset 32 2828b4d142c0
parent 0 e686773b3f54
child 58 d4f567ce2e7c
--- a/predictivesearch/PcsAlgorithm/Algorithm2/src/FindUtilChineseECE.cpp	Tue Apr 27 16:23:35 2010 +0300
+++ b/predictivesearch/PcsAlgorithm/Algorithm2/src/FindUtilChineseECE.cpp	Tue May 11 16:00:21 2010 +0300
@@ -70,6 +70,28 @@
 _LIT(KPanicReason, "Abnormal input parameters!");
 
 const TInt KLitLineFeed(8233);
+
+// CleanupStack helpers for item owning RPointerArrays
+template <class T>
+class CleanupResetAndDestroy
+    {
+public:
+    inline static void PushL( T& aRef )
+        { 
+        CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); 
+        }
+private:
+    inline static void ResetAndDestroy( TAny *aPtr )
+        { 
+        static_cast<T*>( aPtr )->ResetAndDestroy();
+        }
+    };
+
+template <class T>
+inline void CleanupResetAndDestroyPushL( T& aRef )
+    { 
+    CleanupResetAndDestroy<T>::PushL( aRef );
+    }
 // ======== MEMBER FUNCTIONS ========
 
 // ---------------------------------------------------------
@@ -1055,6 +1077,7 @@
 void CFindUtilChineseECE::InsertStrInforArrayL(RPointerArray<STRINGINFO>& aStringInfoArr, 
     TDes &aSegmentStr, const TBool aChinese)
     {
+    CleanupResetAndDestroyPushL( aStringInfoArr );
     if (aSegmentStr.Length() <= 0)
         {
         return;
@@ -1069,6 +1092,7 @@
 
     aStringInfoArr.AppendL(strInfo);
     aSegmentStr.Zero();
+    CleanupStack::Pop( &aStringInfoArr );
     }
 
 // ---------------------------------------------------------