upnpavcontrolpoint/avcpengineclient/src/upnpavcpenginerfsclient.cpp
changeset 34 eab116a48b80
parent 30 5ec426854821
--- a/upnpavcontrolpoint/avcpengineclient/src/upnpavcpenginerfsclient.cpp	Tue Sep 21 11:21:11 2010 +0300
+++ b/upnpavcontrolpoint/avcpengineclient/src/upnpavcpenginerfsclient.cpp	Mon Oct 04 13:32:20 2010 +0300
@@ -39,7 +39,16 @@
     :RUpnpAVCPEngineClient()
     {
     }
-
+	
+// -----------------------------------------------------------------------------
+// Cleanup mechanism
+// -----------------------------------------------------------------------------
+//
+void RUpnpAVCPEngineRFSClient::CleanupArray(TAny* aDirs)
+    {
+    TFileInfo* dirs = (TFileInfo*) aDirs ;
+    delete[] dirs;
+    }
 
 // -----------------------------------------------------------------------------
 // RUpnpAVCPEngineRFSClient::GetDirectoryL
@@ -64,6 +73,7 @@
     	{        
         TFileInfo* dirs = new TFileInfo[size];
         // put array on cleanup stack
+        CleanupStack::PushL(TCleanupItem(CleanupArray, dirs));
         TPtr8 result(reinterpret_cast<TUint8*>(dirs), sizeof(TFileInfo)*size, sizeof(TFileInfo)*size);
         err = SendReceive(EDownloadDirList,TIpcArgs(id, &result));
 
@@ -72,7 +82,7 @@
         	CRsfwDirEnt* entry = GetFileInformationL(dirs[i]);
             aDirList.AppendL(entry);
         	}
-        delete[] dirs;
+        CleanupStack::PopAndDestroy(dirs);
     	}
     return err;
 	}