webengine/osswebengine/MemoryManager/Src/MemoryManager.cpp
changeset 37 cb62a4f66ebe
parent 36 0ed94ceaa377
child 59 1f3c3f2f5b0a
child 65 5bfc169077b2
equal deleted inserted replaced
36:0ed94ceaa377 37:cb62a4f66ebe
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 
    20 
    21 #include "MemoryManager.h"
    21 #include <MemoryManager.h>
    22 #include "MemoryPool.h"
    22 #include "MemoryPool.h"
    23 #include "FastAllocator.h"
    23 #include "FastAllocator.h"
    24 #include "MemoryLogger.h"
    24 #include "MemoryLogger.h"
    25 
    25 
    26 // CONSTANTS
    26 // CONSTANTS
    30 // CLASS DECLARATION
    30 // CLASS DECLARATION
    31 
    31 
    32 //  initializing a global memory pool.
    32 //  initializing a global memory pool.
    33 static CMemoryPool *s_pool = 0;
    33 static CMemoryPool *s_pool = 0;
    34 
    34 
    35 struct cleanupMemoryPool {
       
    36     ~cleanupMemoryPool() {
       
    37     	if(s_pool)
       
    38     		{
       
    39     		delete s_pool;
       
    40     		s_pool = NULL;
       
    41     		}
       
    42     }
       
    43 };
       
    44 static cleanupMemoryPool deleteMemoryPool;
       
    45 
    35 
    46 //-----------------------------------------------------------------------------
    36 //-----------------------------------------------------------------------------
    47 // Pool() - a utility function for accessing the right memory pool
    37 // Pool() - a utility function for accessing the right memory pool
    48 //-----------------------------------------------------------------------------
    38 //-----------------------------------------------------------------------------
    49 inline CMemoryPool* Pool() 
    39 inline CMemoryPool* Pool() 
   111     return User::SwitchAllocator( allocator );
   101     return User::SwitchAllocator( allocator );
   112 #endif
   102 #endif
   113     }
   103     }
   114 
   104 
   115 //-----------------------------------------------------------------------------
   105 //-----------------------------------------------------------------------------
       
   106 // MemoryManager::InitOOMHandler
       
   107 //-----------------------------------------------------------------------------
       
   108 EXPORT_C void MemoryManager::InitOOMDialog()
       
   109     {
       
   110 #ifdef __NEW_ALLOCATOR__
       
   111     if (s_pool)
       
   112         {
       
   113         ((CNewSymbianHeapPool *)s_pool)->InitOOMDialog();
       
   114         }
       
   115 #endif
       
   116     }
       
   117 
       
   118 //-----------------------------------------------------------------------------
       
   119 // MemoryManager::ResetOOMDialogDisplayed
       
   120 //-----------------------------------------------------------------------------
       
   121 EXPORT_C void MemoryManager::ResetOOMDialogDisplayed()
       
   122     {
       
   123 #ifdef __NEW_ALLOCATOR__
       
   124     if (s_pool)
       
   125         {
       
   126         ((CNewSymbianHeapPool *)s_pool)->ResetOOMDialogDisplayed();
       
   127         }
       
   128 #endif
       
   129     }
       
   130 
       
   131 //-----------------------------------------------------------------------------
   116 // MemoryManager::CloseFastAllocator
   132 // MemoryManager::CloseFastAllocator
   117 //-----------------------------------------------------------------------------
   133 //-----------------------------------------------------------------------------
   118 EXPORT_C void MemoryManager::CloseFastAllocator(RAllocator* aDefaultAllocator)
   134 EXPORT_C void MemoryManager::CloseFastAllocator(RAllocator* aDefaultAllocator)
   119     {
   135     {
   120 #ifdef __NEW_ALLOCATOR__
   136 #ifdef __NEW_ALLOCATOR__