|
5 | 5 |
|
6 | 6 | memory_region::memory_region(rust_srv *srv, bool synchronized) :
|
7 | 7 | _srv(srv), _parent(NULL), _live_allocations(0),
|
| 8 | + _detailed_leaks(getenv("RUST_DETAILED_LEAKS") != NULL), |
8 | 9 | _synchronized(synchronized) {
|
9 |
| - // Nop. |
10 | 10 | }
|
11 | 11 |
|
12 | 12 | memory_region::memory_region(memory_region *parent) :
|
13 | 13 | _srv(parent->_srv), _parent(parent), _live_allocations(0),
|
| 14 | + _detailed_leaks(parent->_detailed_leaks), |
14 | 15 | _synchronized(parent->_synchronized) {
|
15 | 16 | // Nop.
|
16 | 17 | }
|
@@ -83,15 +84,28 @@ memory_region::~memory_region() {
|
83 | 84 | }
|
84 | 85 | char msg[128];
|
85 | 86 | snprintf(msg, sizeof(msg),
|
86 |
| - "leaked memory in rust main loop (%" PRIuPTR " objects)", |
87 |
| - _live_allocations); |
| 87 | + "leaked memory in rust main loop (%" PRIuPTR " objects)", |
| 88 | + _live_allocations); |
88 | 89 | #ifdef TRACK_ALLOCATIONS
|
89 |
| - for (size_t i = 0; i < _allocation_list.size(); i++) { |
90 |
| - if (_allocation_list[i] != NULL) { |
91 |
| - printf("allocation 0x%" PRIxPTR " was not freed\n", |
92 |
| - (uintptr_t) _allocation_list[i]); |
| 90 | + if (_detailed_leaks) { |
| 91 | + for (size_t i = 0; i < _allocation_list.size(); i++) { |
| 92 | + if (_allocation_list[i] != NULL) { |
| 93 | + printf("allocation 0x%" PRIxPTR " was not freed\n", |
| 94 | + (uintptr_t) _allocation_list[i]); |
| 95 | + } |
93 | 96 | }
|
94 | 97 | }
|
95 | 98 | #endif
|
96 | 99 | _srv->fatal(msg, __FILE__, __LINE__, "%d objects", _live_allocations);
|
97 | 100 | }
|
| 101 | + |
| 102 | +// |
| 103 | +// Local Variables: |
| 104 | +// mode: C++ |
| 105 | +// fill-column: 78; |
| 106 | +// indent-tabs-mode: nil |
| 107 | +// c-basic-offset: 4 |
| 108 | +// buffer-file-coding-system: utf-8-unix |
| 109 | +// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; |
| 110 | +// End: |
| 111 | +// |
0 commit comments