Skip to content

Commit b367ecf

Browse files
committed
---
yaml --- r: 5117 b: refs/heads/master c: 1262df6 h: refs/heads/master i: 5115: 627f9ce v: v3
1 parent 33c1cdc commit b367ecf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: dabf1be2267439d61029b9b9353f4ae2008a3662
2+
refs/heads/master: 1262df652f766782253fed51526ba60609859719

trunk/src/rt/memory_region.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ void memory_region::dec_alloc() {
3737
void memory_region::free(void *mem) {
3838
// printf("free: ptr 0x%" PRIxPTR" region=%p\n", (uintptr_t) mem, this);
3939
if (!mem) { return; }
40-
if (_synchronized) { _lock.lock(); }
4140
alloc_header *alloc = get_header(mem);
4241
assert(alloc->magic == MAGIC);
4342
if (_live_allocations < 1) {
4443
_srv->fatal("live_allocs < 1", __FILE__, __LINE__, "");
4544
}
4645
release_alloc(mem);
4746
_srv->free(alloc);
48-
if (_synchronized) { _lock.unlock(); }
4947
}
5048

5149
void *
@@ -78,7 +76,6 @@ memory_region::realloc(void *mem, size_t size) {
7876

7977
void *
8078
memory_region::malloc(size_t size, const char *tag, bool zero) {
81-
if (_synchronized) { _lock.lock(); }
8279
size_t old_size = size;
8380
size += sizeof(alloc_header);
8481
alloc_header *mem = (alloc_header *)_srv->malloc(size);
@@ -91,7 +88,6 @@ memory_region::malloc(size_t size, const char *tag, bool zero) {
9188
memset(mem->data, 0, old_size);
9289
}
9390

94-
if (_synchronized) { _lock.unlock(); }
9591
return mem->data;
9692
}
9793

@@ -145,6 +141,7 @@ memory_region::release_alloc(void *mem) {
145141
assert(alloc->magic == MAGIC);
146142

147143
#ifdef TRACK_ALLOCATIONS
144+
if (_synchronized) { _lock.lock(); }
148145
if (_allocation_list[alloc->index] != alloc) {
149146
printf("free: ptr 0x%" PRIxPTR " (%s) is not in allocation_list\n",
150147
(uintptr_t) &alloc->data, alloc->tag);
@@ -155,6 +152,7 @@ memory_region::release_alloc(void *mem) {
155152
_allocation_list[alloc->index] = NULL;
156153
alloc->index = -1;
157154
}
155+
if (_synchronized) { _lock.unlock(); }
158156
#endif
159157
dec_alloc();
160158
}
@@ -164,7 +162,9 @@ memory_region::claim_alloc(void *mem) {
164162
alloc_header *alloc = get_header(mem);
165163
assert(alloc->magic == MAGIC);
166164
#ifdef TRACK_ALLOCATIONS
165+
if (_synchronized) { _lock.lock(); }
167166
alloc->index = _allocation_list.append(alloc);
167+
if (_synchronized) { _lock.unlock(); }
168168
#endif
169169
add_alloc();
170170
}

0 commit comments

Comments
 (0)