--- a/commsfwsupport/commselements/nodemessages/src/nm_interfaces.cpp Thu Aug 19 11:05:47 2010 +0300
+++ b/commsfwsupport/commselements/nodemessages/src/nm_interfaces.cpp Tue Aug 31 16:25:36 2010 +0300
@@ -23,6 +23,7 @@
#include <elements/nm_address_internal.h>
#include "nm_signals.h"
+
#ifdef _DEBUG
// Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
// (if it could happen through user error then you should give it an explicit, documented, category + code)
@@ -139,9 +140,10 @@
iClientType = TClientType::NullType();
if(iPreAlloc!=NULL)
{
- delete iPreAlloc;
- iPreAlloc = NULL;
+ delete iPreAlloc->iPreAllocatedActivityChunk;
}
+ delete iPreAlloc;
+ iPreAlloc = NULL;
}
EXPORT_C void RNodeInterface::PostMessage(const TRuntimeCtxId& aPostFrom, const TNodeId::TRemainder& aPostTo, const TSignalBase& aMessage) const
@@ -169,28 +171,11 @@
if(iPreAlloc!=NULL)
// Memory already allocated for this client
{
- // If iPreAlloc is not NULL then it should be usable. Ensure that the memory chunk has been suitable allocated
- __ASSERT_DEBUG(iPreAlloc->iPreAllocatedActivityChunk != NULL, User::Panic(KSpecAssert_ElemNodeMessIntC, 2));
- if(iPreAlloc->iPreAllocSize >= aAllocSize)
- // Memory already preallocated of a sufficient size - this could happen if clients are re-added
- {
- return;
- }
- else
- // Memory preallocated is too small. Free up the space and then attempt to reallocate
- {
- // Code path should never enter here as PreAllocL should not be called once the iPreAlloc memory space is allocated.
- // However on the chance of production device entering here attempt to clear the preallocated space and reallocate a more suitable amount.
- __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ElemNodeMessIntC, 3));
- delete iPreAlloc;
- iPreAlloc = NULL;
- }
+ __ASSERT_DEBUG(iPreAlloc->iPreAllocatedActivityChunk != NULL, User::Panic(KSpecAssert_ElemNodeMessIntC, 5));
+ return;
}
- TPreAllocStore* preAlloc = new (ELeave) TPreAllocStore();
- CleanupStack::PushL(preAlloc);
- preAlloc->iPreAllocatedActivityChunk = User::AllocL(aAllocSize);
- CleanupStack::Pop(preAlloc);
- iPreAlloc = preAlloc;
+ iPreAlloc = new (ELeave) TPreAllocStore();
+ iPreAlloc->iPreAllocatedActivityChunk = User::AllocL(aAllocSize);
iPreAlloc->iPreAllocSize = aAllocSize;
}
@@ -203,15 +188,12 @@
if(!(iPreAlloc && aSize <= iPreAlloc->iPreAllocSize))
{
// By this stage the PreAllocL must have been triggered and memory space must have been allocated.
- __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ElemNodeMessIntC, 4));
- TRAPD(err,PreAllocL(aSize));
- __ASSERT_ALWAYS(err, User::Panic(KMessagesPanic, EPreAllocationFailedPanic));
+ __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ElemNodeMessIntC, 3));
+ delete iPreAlloc->iPreAllocatedActivityChunk;
+ iPreAlloc->iPreAllocatedActivityChunk = User::AllocL(aSize);
}
TAny* preallocatedSpace = (RNodeInterface*)iPreAlloc->iPreAllocatedActivityChunk;
- // Release ownership of the memory area
- iPreAlloc->iPreAllocatedActivityChunk = NULL;
- delete iPreAlloc;
- iPreAlloc = NULL;
+ iPreAlloc->iPreAllocatedActivityChunk=NULL;
return preallocatedSpace;
}
@@ -270,7 +252,7 @@
EXPORT_C void RRequestOriginator::Open(RRequestOriginator& aOriginalRequest)
{
- __ASSERT_DEBUG(aOriginalRequest.IsOpen(), User::Panic(KSpecAssert_ElemNodeMessIntC, 1));
+ __ASSERT_DEBUG(aOriginalRequest.IsOpen(), User::Panic(KSpecAssert_ElemNodeMessIntC, 4));
iNode = aOriginalRequest.iNode;
iRemainder = aOriginalRequest.iRemainder;
aOriginalRequest.Close();