Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /*==================================================================================================
     18 
     19     Source Name: dmAllocatedPointersPool.cc
     20 
     21     General Description: Implementation of the DMAllocatedPointersPool class
     22 
     23 ==================================================================================================*/
     24 
     25 #include "dmMemory.h"
     26 #include "dmThreadHelper.h"
     27 #include <stdio.h>
     28 #include <sys/time.h>
     29 #include <signal.h>
     30 #include "dmAllocatedPointersPool.h"
     31 
     32 #ifdef DEBUG
     33 DMAllocatedPointersPool::~DMAllocatedPointersPool()
     34 {
     35 #ifdef DEBUG
     36   //PrintUnreleased();
     37 #endif
     38 }
     39 
     40 void DMAllocatedPointersPool::PrintUnreleased()
     41 {
     42   DMSingleLock oLock( m_csPointerPoolLock );
     43 
     44   std::map<void*, int>::const_iterator vli = m_listOfAllocatedPointers.begin();
     45   int nBlockNum = 1;
     46 
     47   while (vli != m_listOfAllocatedPointers.end())
     48   {
     49     const char *ptr = (const char*)(const void*)vli->first;
     50     CPCHAR* ppStr = (CPCHAR*)ptr;
     51 
     52     ptr += 3*sizeof(const char*) + DMAllocatedPointersPool::c_nExtraBytes;
     53 
     54     printf( "%d. block (%d bytes) with addr %p was not deallocated; file %s, line %d\n",
     55       nBlockNum++, (int)ppStr[2], ptr, ppStr[0], (int)ppStr[1] );
     56     vli++;
     57   }
     58   if ( nBlockNum > 1 )
     59     printf( "\n" );
     60 
     61   //m_listOfAllocatedPointers.clear();
     62 }
     63 #endif //DEBUG
     64