11 #include "wxartbaseprec.h"
29 for( a2dFreeList* fl = m_allLists; fl != NULL; )
31 wxASSERT( m_count > 0 );
32 for(
void* space = fl->m_topOfList; space != NULL; )
34 wxASSERT( fl->m_count > 0 );
35 void* itemForDestroy = space;
36 space = *( (
void** )space );
37 delete itemForDestroy;
40 a2dFreeList* forDestroy = fl;
50 for( a2dFreeList* fl = m_allLists;
54 if( fl->m_blockSize == bytes )
56 if( fl->m_topOfList != NULL )
58 void* space = fl->m_topOfList;
59 fl->m_topOfList = *( (
void** )( fl->m_topOfList ) );
61 wxASSERT( ( fl->m_topOfList == NULL && fl->m_count == 0 ) || ( fl->m_topOfList != NULL && fl->m_count != 0 ) );
67 void* newpointer = ::operator
new( bytes );
76 for( fl = m_allLists; fl != NULL; fl = fl->m_next )
78 if( fl->m_blockSize == bytes )
83 fl =
new a2dFreeList( m_allLists, bytes );
88 *( (
void** )space ) = fl->m_topOfList;
89 fl->m_topOfList = space;
95 #include "wx/stackwalk.h"
97 wxString a2dGetStackTrace(
size_t skip,
bool withArgs,
int maxCalls,
int maxLines )
101 class StackDump :
public wxStackWalker
104 StackDump(
int maxCalls = 20,
bool withArgs =
false ) { m_curCall = 0; m_maxCalls = maxCalls; m_withArgs = withArgs; }
106 const wxString& GetStackTrace()
const {
return m_stackTrace; }
109 virtual void OnStackFrame(
const wxStackFrame& frame )
111 if( m_curCall >= m_maxCalls )
114 m_stackTrace << wxString::Format( _T(
"\t[%02d] " ), frame.GetLevel() );
116 wxString name = frame.GetName();
119 m_stackTrace << wxString::Format( _T(
"%-40s" ), name.c_str() );
123 m_stackTrace << wxString::Format
126 (
unsigned long )frame.GetAddress()
134 for ( n = 0; frame.GetParam( n, &type, &name, &val ); n++ )
137 m_stackTrace << wxT(
"\t(" );
139 m_stackTrace << wxT(
", " );
140 m_stackTrace << wxString::Format( wxT(
"%s %s=%s" ), type.c_str(), name.c_str(), val.Find( wxT(
'\n' ) ) == wxNOT_FOUND ? val.c_str() : wxT(
"..." ) );
143 m_stackTrace << wxT(
" )" );
146 if ( frame.HasSourceLocation() )
148 m_stackTrace << _T(
'\t' )
149 << frame.GetFileName()
154 m_stackTrace << _T(
'\n' );
158 wxString m_stackTrace;
164 StackDump dump( maxCalls, withArgs );
166 stackTrace = dump.GetStackTrace();
171 const int count = stackTrace.Freq( wxT(
'\n' ) );
172 for (
int i = 0; i < count - maxLines; i++ )
173 stackTrace = stackTrace.BeforeLast( wxT(
'\n' ) );
177 #endif // wxUSE_STACKWALKER
178 #endif // __WXDEBUG__
~a2dMemManager()
destructor of memory manager
void Deallocate(void *space, size_t bytes)
function for adding memory block by size bytes to list of freed memory blocks
void * Allocate(size_t bytes)
function for allocating memory block by size bytes
memory management which can optionally be used for certain intensively used classes.