memana/analyzetoolclient/commandlineengine/internal/src/catalloc.cpp
changeset 0 f0f2b8682603
equal deleted inserted replaced
-1:000000000000 0:f0f2b8682603
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 #include "../inc/ATCommonDefines.h"
       
    18 #include "../inc/catalloc.h"
       
    19 
       
    20 string CATAlloc::GetAllocString( void )
       
    21 {
       
    22 	LOG_LOW_FUNC_ENTRY("CATAlloc::GetAllocString");
       
    23 	// Create alloc string
       
    24 	string sLine("");
       
    25 	sLine.append( m_sTime ); sLine.append(" " );
       
    26 	sLine.append( m_sSize );
       
    27 
       
    28 	// Add all call stack fragments to line.
       
    29 	string sCallStack;
       
    30 	map<unsigned long, string>::iterator it;
       
    31 	for( it = m_vCallStack.begin() ; it != m_vCallStack.end() ; it++ )
       
    32 	{
       
    33 		sCallStack.append( (*it).second );
       
    34 		sCallStack.append( " " );
       
    35 	}
       
    36 	// Remove the last space
       
    37 	if ( sCallStack.size() > 0 )
       
    38 		sCallStack.erase( sCallStack.size()-1, 1 );
       
    39 	
       
    40 	if ( m_iCSCount != 0 )
       
    41 	{
       
    42 		// Check integrity (calculate number of spaces in call stack)
       
    43 		unsigned long iCount = 0;
       
    44 		size_t pos = 0;
       
    45 		while ( pos != string::npos )
       
    46 		{
       
    47 			iCount++;
       
    48 			pos = sCallStack.find_first_of( ' ', pos+1 );
       
    49 		}
       
    50 		if ( iCount != m_iCSCount )
       
    51 			cout << AT_MSG << "Error, integrity check failed in alloc." << endl;
       
    52 	}
       
    53 
       
    54 	// Add call stack to line.
       
    55 	if ( sCallStack.size() > 0 )
       
    56 	{
       
    57 		sLine.append(" " );
       
    58 		sLine.append( sCallStack );
       
    59 	}
       
    60 
       
    61 	// return alloc line.
       
    62 	return sLine;
       
    63 }
       
    64