commsfwsupport/commselements/meshmachine/src/mm_node.cpp
branchRCL_3
changeset 26 b564fb5fd78b
parent 25 9d7ce34704c8
--- a/commsfwsupport/commselements/meshmachine/src/mm_node.cpp	Tue Aug 31 16:25:36 2010 +0300
+++ b/commsfwsupport/commselements/meshmachine/src/mm_node.cpp	Wed Sep 01 12:35:48 2010 +0100
@@ -735,7 +735,10 @@
 	if(!freeCellFound)
 		{
 		MESH_LOG((KMeshMachineSubTag, _L8("ERROR AMMNodeBase %08x:\tBorrowPreallocatedSpace - All %d preallocation cells have been allocated!"), this, maxPreallocatedActivities));
-		__ASSERT_ALWAYS(freeCellFound, User::Panic(KMMNodePanic, EPanicPreallocatedSpaceAlreadyTaken));
+		__ASSERT_DEBUG(freeCellFound, User::Panic(KMMNodePanic, EPanicPreallocatedSpaceAlreadyTaken));
+		// Attempt to allocate some space from the heap now in a last attempt to continue processing.
+		TRAPD(err,ptr =  User::AllocL(aSize));
+		__ASSERT_ALWAYS(err, User::Panic(KMessagesPanic, EPreAllocationFailedPanic));
 		}
 
 	return ptr;
@@ -766,6 +769,8 @@
 		{
 		MESH_LOG((KMeshMachineSubTag, _L8("ERROR AMMNodeBase %08x:\tReturnPreallocatedSpace - the returned pointer 0x%08X is invalid!"), this, aSpace));
 		__ASSERT_DEBUG(allocatedCellFound, User::Panic(KMMNodePanic, EPanicPreallocatedSpaceReturnedOther));
+		// May be returning a cell which was created in error recovery section of the Borrow in which case if must be "free"d.
+		User::Free(aSpace);
 		}
 	}