21 #include "nm_interfaces.h" |
21 #include "nm_interfaces.h" |
22 #include <elements/nm_transport.h> |
22 #include <elements/nm_transport.h> |
23 #include <elements/nm_address_internal.h> |
23 #include <elements/nm_address_internal.h> |
24 #include "nm_signals.h" |
24 #include "nm_signals.h" |
25 |
25 |
|
26 |
26 #ifdef _DEBUG |
27 #ifdef _DEBUG |
27 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
28 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
28 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
29 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
29 _LIT(KSpecAssert_ElemNodeMessIntC, "ElemNodeMessIntC"); |
30 _LIT(KSpecAssert_ElemNodeMessIntC, "ElemNodeMessIntC"); |
30 #endif |
31 #endif |
137 { |
138 { |
138 RClientInterface::Close(); |
139 RClientInterface::Close(); |
139 iClientType = TClientType::NullType(); |
140 iClientType = TClientType::NullType(); |
140 if(iPreAlloc!=NULL) |
141 if(iPreAlloc!=NULL) |
141 { |
142 { |
142 delete iPreAlloc; |
143 delete iPreAlloc->iPreAllocatedActivityChunk; |
143 iPreAlloc = NULL; |
144 } |
144 } |
145 delete iPreAlloc; |
|
146 iPreAlloc = NULL; |
145 } |
147 } |
146 |
148 |
147 EXPORT_C void RNodeInterface::PostMessage(const TRuntimeCtxId& aPostFrom, const TNodeId::TRemainder& aPostTo, const TSignalBase& aMessage) const |
149 EXPORT_C void RNodeInterface::PostMessage(const TRuntimeCtxId& aPostFrom, const TNodeId::TRemainder& aPostTo, const TSignalBase& aMessage) const |
148 { |
150 { |
149 TUint8 postTo[__Align8(TRuntimeCtxId::KMaxInlineAddressSize)]; |
151 TUint8 postTo[__Align8(TRuntimeCtxId::KMaxInlineAddressSize)]; |
167 */ |
169 */ |
168 { |
170 { |
169 if(iPreAlloc!=NULL) |
171 if(iPreAlloc!=NULL) |
170 // Memory already allocated for this client |
172 // Memory already allocated for this client |
171 { |
173 { |
172 // If iPreAlloc is not NULL then it should be usable. Ensure that the memory chunk has been suitable allocated |
174 __ASSERT_DEBUG(iPreAlloc->iPreAllocatedActivityChunk != NULL, User::Panic(KSpecAssert_ElemNodeMessIntC, 5)); |
173 __ASSERT_DEBUG(iPreAlloc->iPreAllocatedActivityChunk != NULL, User::Panic(KSpecAssert_ElemNodeMessIntC, 2)); |
175 return; |
174 if(iPreAlloc->iPreAllocSize >= aAllocSize) |
176 } |
175 // Memory already preallocated of a sufficient size - this could happen if clients are re-added |
177 iPreAlloc = new (ELeave) TPreAllocStore(); |
176 { |
178 iPreAlloc->iPreAllocatedActivityChunk = User::AllocL(aAllocSize); |
177 return; |
|
178 } |
|
179 else |
|
180 // Memory preallocated is too small. Free up the space and then attempt to reallocate |
|
181 { |
|
182 // Code path should never enter here as PreAllocL should not be called once the iPreAlloc memory space is allocated. |
|
183 // However on the chance of production device entering here attempt to clear the preallocated space and reallocate a more suitable amount. |
|
184 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ElemNodeMessIntC, 3)); |
|
185 delete iPreAlloc; |
|
186 iPreAlloc = NULL; |
|
187 } |
|
188 } |
|
189 TPreAllocStore* preAlloc = new (ELeave) TPreAllocStore(); |
|
190 CleanupStack::PushL(preAlloc); |
|
191 preAlloc->iPreAllocatedActivityChunk = User::AllocL(aAllocSize); |
|
192 CleanupStack::Pop(preAlloc); |
|
193 iPreAlloc = preAlloc; |
|
194 iPreAlloc->iPreAllocSize = aAllocSize; |
179 iPreAlloc->iPreAllocSize = aAllocSize; |
195 } |
180 } |
196 |
181 |
197 EXPORT_C TAny* RNodeInterface::ClaimPreallocatedSpace(TUint aSize) |
182 EXPORT_C TAny* RNodeInterface::ClaimPreallocatedSpace(TUint aSize) |
198 /** Finds a pointer of the requested size from the preallocation array (see PreallocActivitySpaceL) and returns it |
183 /** Finds a pointer of the requested size from the preallocation array (see PreallocActivitySpaceL) and returns it |
201 */ |
186 */ |
202 { |
187 { |
203 if(!(iPreAlloc && aSize <= iPreAlloc->iPreAllocSize)) |
188 if(!(iPreAlloc && aSize <= iPreAlloc->iPreAllocSize)) |
204 { |
189 { |
205 // By this stage the PreAllocL must have been triggered and memory space must have been allocated. |
190 // By this stage the PreAllocL must have been triggered and memory space must have been allocated. |
206 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ElemNodeMessIntC, 4)); |
191 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ElemNodeMessIntC, 3)); |
207 TRAPD(err,PreAllocL(aSize)); |
192 delete iPreAlloc->iPreAllocatedActivityChunk; |
208 __ASSERT_ALWAYS(err, User::Panic(KMessagesPanic, EPreAllocationFailedPanic)); |
193 iPreAlloc->iPreAllocatedActivityChunk = User::AllocL(aSize); |
209 } |
194 } |
210 TAny* preallocatedSpace = (RNodeInterface*)iPreAlloc->iPreAllocatedActivityChunk; |
195 TAny* preallocatedSpace = (RNodeInterface*)iPreAlloc->iPreAllocatedActivityChunk; |
211 // Release ownership of the memory area |
196 iPreAlloc->iPreAllocatedActivityChunk=NULL; |
212 iPreAlloc->iPreAllocatedActivityChunk = NULL; |
|
213 delete iPreAlloc; |
|
214 iPreAlloc = NULL; |
|
215 return preallocatedSpace; |
197 return preallocatedSpace; |
216 } |
198 } |
217 |
199 |
218 /****************************************************************************************************** |
200 /****************************************************************************************************** |
219 * |
201 * |
268 return KErrArgument; |
250 return KErrArgument; |
269 } |
251 } |
270 |
252 |
271 EXPORT_C void RRequestOriginator::Open(RRequestOriginator& aOriginalRequest) |
253 EXPORT_C void RRequestOriginator::Open(RRequestOriginator& aOriginalRequest) |
272 { |
254 { |
273 __ASSERT_DEBUG(aOriginalRequest.IsOpen(), User::Panic(KSpecAssert_ElemNodeMessIntC, 1)); |
255 __ASSERT_DEBUG(aOriginalRequest.IsOpen(), User::Panic(KSpecAssert_ElemNodeMessIntC, 4)); |
274 iNode = aOriginalRequest.iNode; |
256 iNode = aOriginalRequest.iNode; |
275 iRemainder = aOriginalRequest.iRemainder; |
257 iRemainder = aOriginalRequest.iRemainder; |
276 aOriginalRequest.Close(); |
258 aOriginalRequest.Close(); |
277 } |
259 } |
278 |
260 |