connectivitylayer/isce/memmanager_dll/src/memmanager.cpp
changeset 5 8ccc39f9d787
parent 0 63b37f68c1ce
child 9 8486d82aef45
equal deleted inserted replaced
4:510c70acdbf6 5:8ccc39f9d787
   122         )
   122         )
   123     {
   123     {
   124     C_TRACE( ( _T( "DMemManager::PoolAllocateDfc aPtr 0x%x>" ), aPtr ) );
   124     C_TRACE( ( _T( "DMemManager::PoolAllocateDfc aPtr 0x%x>" ), aPtr ) );
   125             
   125             
   126     DMemManager& tmp = *reinterpret_cast<DMemManager*>( aPtr );
   126     DMemManager& tmp = *reinterpret_cast<DMemManager*>( aPtr );
       
   127     TRACE_ASSERT_ALWAYS;// See below TODO comment, needs a fix
   127     
   128     
   128     NKern::FMWait( tmp.iFastMutex );
   129     NKern::FMWait( tmp.iFastMutex );
   129     
   130     
   130     ASSERT_RESET_ALWAYS( ( tmp.iPoolCreateQueue.Count() > 0 ), ( EInvalidQueueCount | EDMemmanagerTraceId << KClassIdentifierShift ) );
   131     ASSERT_RESET_ALWAYS( ( tmp.iPoolCreateQueue.Count() > 0 ), ( EInvalidQueueCount | EDMemmanagerTraceId << KClassIdentifierShift ) );
   131     TInt index = tmp.iMemPond.Find( tmp.iPoolCreateQueue[0] );
   132     TInt index = tmp.iMemPond.Find( tmp.iPoolCreateQueue[0] );
   146         )
   147         )
   147     {
   148     {
   148     C_TRACE( ( _T( "DMemManager::PoolDeleteDfc aPtr 0x%x>" ), aPtr ) );
   149     C_TRACE( ( _T( "DMemManager::PoolDeleteDfc aPtr 0x%x>" ), aPtr ) );
   149             
   150             
   150     DMemManager& tmp = *reinterpret_cast<DMemManager*>( aPtr );
   151     DMemManager& tmp = *reinterpret_cast<DMemManager*>( aPtr );
   151     
   152     TRACE_ASSERT_ALWAYS; // See below TODO comment, needs a fix
   152     NKern::FMWait( tmp.iFastMutex );
   153     NKern::FMWait( tmp.iFastMutex );
   153     
   154     
   154     ASSERT_RESET_ALWAYS( ( tmp.iPoolDeleteQueue.Count() > 0 ), ( EInvalidQueueCount | EDMemmanagerTraceId << KClassIdentifierShift ) );
   155     ASSERT_RESET_ALWAYS( ( tmp.iPoolDeleteQueue.Count() > 0 ), ( EInvalidQueueCount | EDMemmanagerTraceId << KClassIdentifierShift ) );
   155     delete tmp.iPoolDeleteQueue[0];
   156     delete tmp.iPoolDeleteQueue[0];
   156     tmp.iPoolDeleteQueue.Remove(0);
   157     tmp.iPoolDeleteQueue.Remove(0);
   255 /*
   256 /*
   256 * Allocate memory unit.
   257 * Allocate memory unit.
   257 */
   258 */
   258 TPtr8* DMemManager::DMemPool::Alloc( const TUint16 aSize )
   259 TPtr8* DMemManager::DMemPool::Alloc( const TUint16 aSize )
   259     {
   260     {
   260 	  C_TRACE( ( _T( "DMemManager::DMemPool::Alloc>" ) ) );
   261 // TODO : not when FM	  C_TRACE( ( _T( "DMemManager::DMemPool::Alloc>" ) ) );
   261 	  
   262 	  
   262 	  ASSERT_RESET_ALWAYS( (iMemoryArea || iFreeMemBlock), ( EMemBlockAllocationFailed | EDMemmanagerTraceId << KClassIdentifierShift ) );
   263 	  ASSERT_RESET_ALWAYS( (iMemoryArea || iFreeMemBlock), ( EMemBlockAllocationFailed | EDMemmanagerTraceId << KClassIdentifierShift ) );
   263     
   264     
   264     struct sUnit *pCurUnit = iFreeMemBlock;
   265     struct sUnit *pCurUnit = iFreeMemBlock;
   265 
   266 
   279 
   280 
   280     iAllocatedMemBlock = pCurUnit;
   281     iAllocatedMemBlock = pCurUnit;
   281     
   282     
   282     iBlockUsage++;
   283     iBlockUsage++;
   283    
   284    
   284 	  C_TRACE( ( _T( "DMemManager::DMemPool::Alloc<" ) ) );
   285 // TODO : not when FM	  C_TRACE( ( _T( "DMemManager::DMemPool::Alloc<" ) ) );
   285     return iAllocatedMemBlock->iMemPtr;
   286     return iAllocatedMemBlock->iMemPtr;
   286     }
   287     }
   287 
   288 
   288 
   289 
   289 /*
   290 /*
   290 * Free memory unit.
   291 * Free memory unit.
   291 */
   292 */
   292 TBool DMemManager::DMemPool::Free( const TUint8* aBlockAddress )
   293 TBool DMemManager::DMemPool::Free( const TUint8* aBlockAddress )
   293     {
   294     {
   294     C_TRACE( ( _T( "DMemManager::DMemPool::Free>" ) ) );
   295 // TODO : not when FM    C_TRACE( ( _T( "DMemManager::DMemPool::Free>" ) ) );
   295 	    
   296 	    
   296     struct sUnit *pCurUnit = (struct sUnit *)(aBlockAddress - sizeof(struct sUnit) );
   297     struct sUnit *pCurUnit = (struct sUnit *)(aBlockAddress - sizeof(struct sUnit) );
   297 
   298 
   298     iAllocatedMemBlock = pCurUnit->iNext;
   299     iAllocatedMemBlock = pCurUnit->iNext;
   299         
   300         
   311 
   312 
   312     iFreeMemBlock = pCurUnit;
   313     iFreeMemBlock = pCurUnit;
   313     iFreeMemBlock->iMemPtr->Zero();
   314     iFreeMemBlock->iMemPtr->Zero();
   314     iBlockUsage--;
   315     iBlockUsage--;
   315     
   316     
   316     C_TRACE( ( _T( "DMemManager::DMemPool::Free<" ) ) );
   317 // TODO : not when FM    C_TRACE( ( _T( "DMemManager::DMemPool::Free<" ) ) );
   317 
   318 
   318     //If empty & ready to be deleted
   319     //If empty & ready to be deleted
   319     return ( iCopyPoolInUse && iBlockUsage == 0 ) ? ETrue : EFalse; 
   320     return ( iCopyPoolInUse && iBlockUsage == 0 ) ? ETrue : EFalse; 
   320  
   321  
   321     }
   322     }