diff -r 0d28c1c5b6dd -r 2828b4d142c0 predictivesearch/PcsAlgorithm/Algorithm2/src/FindUtilChineseECE.cpp --- 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 CleanupResetAndDestroy + { +public: + inline static void PushL( T& aRef ) + { + CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); + } +private: + inline static void ResetAndDestroy( TAny *aPtr ) + { + static_cast( aPtr )->ResetAndDestroy(); + } + }; + +template +inline void CleanupResetAndDestroyPushL( T& aRef ) + { + CleanupResetAndDestroy::PushL( aRef ); + } // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------- @@ -1055,6 +1077,7 @@ void CFindUtilChineseECE::InsertStrInforArrayL(RPointerArray& 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 ); } // ---------------------------------------------------------