@@ -42,30 +42,25 @@ inline void memory_region::maybe_print_backtrace(const alloc_header *header) con
42
42
# endif
43
43
}
44
44
45
- memory_region::memory_region (bool synchronized,
46
- bool detailed_leaks,
45
+ memory_region::memory_region (bool detailed_leaks,
47
46
bool poison_on_free) :
48
47
_parent(NULL ), _live_allocations(0 ),
49
48
_detailed_leaks(detailed_leaks),
50
- _poison_on_free(poison_on_free),
51
- _synchronized(synchronized) {
49
+ _poison_on_free(poison_on_free) {
52
50
}
53
51
54
52
memory_region::memory_region (memory_region *parent) :
55
53
_parent(parent), _live_allocations(0 ),
56
54
_detailed_leaks(parent->_detailed_leaks),
57
- _poison_on_free(parent->_poison_on_free),
58
- _synchronized(parent->_synchronized) {
55
+ _poison_on_free(parent->_poison_on_free) {
59
56
}
60
57
61
58
void memory_region::add_alloc () {
62
- // _live_allocations++;
63
- sync::increment (_live_allocations);
59
+ _live_allocations++;
64
60
}
65
61
66
62
void memory_region::dec_alloc () {
67
- // _live_allocations--;
68
- sync::decrement (_live_allocations);
63
+ _live_allocations--;
69
64
}
70
65
71
66
void memory_region::free (void *mem) {
@@ -112,7 +107,6 @@ memory_region::realloc(void *mem, size_t orig_size) {
112
107
# endif
113
108
114
109
# if RUSTRT_TRACK_ALLOCATIONS >= 2
115
- if (_synchronized) { _lock.lock (); }
116
110
if (_allocation_list[newMem->index ] != alloc) {
117
111
printf (" at index %d, found %p, expected %p\n " ,
118
112
alloc->index , _allocation_list[alloc->index ], alloc);
@@ -125,7 +119,6 @@ memory_region::realloc(void *mem, size_t orig_size) {
125
119
// printf("realloc: stored %p at index %d, replacing %p\n",
126
120
// newMem, index, mem);
127
121
}
128
- if (_synchronized) { _lock.unlock (); }
129
122
# endif
130
123
131
124
return get_data (newMem);
@@ -160,9 +153,7 @@ memory_region::malloc(size_t size, const char *tag) {
160
153
}
161
154
162
155
memory_region::~memory_region () {
163
- if (_synchronized) { _lock.lock (); }
164
156
if (_live_allocations == 0 && !_detailed_leaks) {
165
- if (_synchronized) { _lock.unlock (); }
166
157
return ;
167
158
}
168
159
char msg[128 ];
@@ -193,7 +184,6 @@ memory_region::~memory_region() {
193
184
fprintf (stderr, " %s\n " , msg);
194
185
assert (false );
195
186
}
196
- if (_synchronized) { _lock.unlock (); }
197
187
}
198
188
199
189
void
@@ -204,7 +194,6 @@ memory_region::release_alloc(void *mem) {
204
194
# endif
205
195
206
196
# if RUSTRT_TRACK_ALLOCATIONS >= 2
207
- if (_synchronized) { _lock.lock (); }
208
197
if (((size_t ) alloc->index ) >= _allocation_list.size ()) {
209
198
printf (" free: ptr 0x%" PRIxPTR " (%s) index %d is beyond allocation_list of size %zu\n " ,
210
199
(uintptr_t ) get_data (alloc), alloc->tag , alloc->index , _allocation_list.size ());
@@ -222,7 +211,6 @@ memory_region::release_alloc(void *mem) {
222
211
_allocation_list[alloc->index ] = NULL ;
223
212
alloc->index = -1 ;
224
213
}
225
- if (_synchronized) { _lock.unlock (); }
226
214
# endif
227
215
228
216
dec_alloc ();
@@ -236,9 +224,7 @@ memory_region::claim_alloc(void *mem) {
236
224
# endif
237
225
238
226
# if RUSTRT_TRACK_ALLOCATIONS >= 2
239
- if (_synchronized) { _lock.lock (); }
240
227
alloc->index = _allocation_list.append (alloc);
241
- if (_synchronized) { _lock.unlock (); }
242
228
# endif
243
229
244
230
# if RUSTRT_TRACK_ALLOCATIONS >= 3
0 commit comments