Changeset 1cb7fab2 for src/Common/Stats/Heap.cc
- Timestamp:
- Mar 4, 2019, 2:53:55 PM (5 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 874ffa4
- Parents:
- 675716e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/Stats/Heap.cc
r675716e r1cb7fab2 21 21 #include <iostream> 22 22 23 #if defined( NO_STATISTICS ) 24 #define NO_HEAP_STATISTICS 25 #endif 26 23 27 namespace Stats { 24 28 namespace Heap { … … 28 32 void print() {} 29 33 #else 34 extern bool enabled; 35 30 36 struct StatBlock { 31 37 const char * name = nullptr; ///< Name of this pass … … 77 83 78 84 void print() { 85 if(!enabled) return; 86 79 87 size_t nc = 0; 80 88 size_t total_mallocs = 0; … … 166 174 void * malloc( size_t size ) { 167 175 static auto __malloc = reinterpret_cast<void * (*)(size_t)>(interpose_symbol( "malloc", nullptr )); 168 if( passes_cnt > 0 ) {176 if( enabled && passes_cnt > 0 ) { 169 177 passes[passes_cnt - 1].mallocs++; 170 178 passes[passes_cnt - 1].n_allocs++; … … 177 185 void free( void * ptr ) { 178 186 static auto __free = reinterpret_cast<void (*)(void *)>(interpose_symbol( "free", nullptr )); 179 if( passes_cnt > 0 ) {187 if( enabled && passes_cnt > 0 ) { 180 188 passes[passes_cnt - 1].frees++; 181 189 passes[passes_cnt - 1].n_allocs--; … … 186 194 void * calloc( size_t nelem, size_t size ) { 187 195 static auto __calloc = reinterpret_cast<void * (*)(size_t, size_t)>(interpose_symbol( "calloc", nullptr )); 188 if( passes_cnt > 0 ) {196 if( enabled && passes_cnt > 0 ) { 189 197 passes[passes_cnt - 1].mallocs++; 190 198 passes[passes_cnt - 1].n_allocs++; … … 198 206 static auto __realloc = reinterpret_cast<void * (*)(void *, size_t)>(interpose_symbol( "realloc", nullptr )); 199 207 void * s = __realloc( ptr, size ); 200 if ( s != ptr && passes_cnt > 0 ) { // did realloc get new storage ?208 if ( enabled && s != ptr && passes_cnt > 0 ) { // did realloc get new storage ? 201 209 passes[passes_cnt - 1].mallocs++; 202 210 passes[passes_cnt - 1].frees++;
Note: See TracChangeset
for help on using the changeset viewer.