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 #include "dmMemory.h" 18 #include "dmThreadHelper.h" 19 #include <stdio.h> 20 #include <sys/time.h> 21 #include <signal.h> 22 #include "dmAllocatedPointersPool.h" 23 24 #ifdef DEBUG 25 DMAllocatedPointersPool::~DMAllocatedPointersPool() 26 { 27 #ifdef DEBUG 28 //PrintUnreleased(); 29 #endif 30 } 31 32 void DMAllocatedPointersPool::PrintUnreleased() 33 { 34 DMSingleLock oLock( m_csPointerPoolLock ); 35 36 std::map<void*, int>::const_iterator vli = m_listOfAllocatedPointers.begin(); 37 int nBlockNum = 1; 38 39 while (vli != m_listOfAllocatedPointers.end()) 40 { 41 const char *ptr = (const char*)(const void*)vli->first; 42 CPCHAR* ppStr = (CPCHAR*)ptr; 43 44 ptr += 3*sizeof(const char*) + DMAllocatedPointersPool::c_nExtraBytes; 45 46 printf( "%d. block (%d bytes) with addr %p was not deallocated; file %s, line %d\n", 47 nBlockNum++, (int)ppStr[2], ptr, ppStr[0], (int)ppStr[1] ); 48 vli++; 49 } 50 if ( nBlockNum > 1 ) 51 printf( "\n" ); 52 53 //m_listOfAllocatedPointers.clear(); 54 } 55 #endif //DEBUG 56