1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  *
5  * $Revision: 8948 $
6  * $Id: blockallocated.cpp 8948 2013-04-06 17:15:49Z alpha0010 $
7  * $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/branches/release-20.xx/src/sdk/blockallocated.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 
12 #ifndef CB_PRECOMP
13     #include <wx/log.h> // for wxSafeShowMessage()
14     #include <wx/regex.h>
15 #endif
16 #include "blockallocated.h"
17 
18 namespace BlkAllc
19 {
20 
DebugLog(wxString cn,int blockSize,int poolSize,int max_refs,int total_refs,int ref_count)21     void DebugLog(wxString cn, int blockSize, int poolSize, int max_refs, int total_refs, int ref_count)
22     {
23         wxString s;
24         wxString cn2;
25 
26         if(total_refs == 0)
27             return; // pointless
28 
29         wxRegEx r(_T("^[A-Z]?[0-9]+(.*)"));
30         if(r.Matches(cn))
31             cn2 = r.GetMatch(cn, 1);
32 
33         s.Printf(_T("%s\n\n%d reserved pools of size %d (%d total objects)\n"
34         "Maximum number of allocated objects: %d\n"
35         "Total number of allocations: %d\n"
36         "Number of stale objects: %d %s"),
37         cn2.c_str(),
38         blockSize, poolSize, blockSize * poolSize,
39         max_refs, total_refs, ref_count, (ref_count == 0 ? _T("") : _T("(memory leak)")));
40 
41         wxSafeShowMessage(_T("Block Allocator"), s);
42     } // end of DebugLog
43 }
44