Skip to content

Commit 1a41b48

Browse files
committed
rm the unused calloc wrapper from memory_region
it doesn't actually call calloc, so it's fairly pointless
1 parent 2e06147 commit 1a41b48

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

src/rt/memory_region.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ memory_region::realloc(void *mem, size_t orig_size) {
121121
}
122122

123123
void *
124-
memory_region::malloc(size_t size, const char *tag, bool zero) {
124+
memory_region::malloc(size_t size, const char *tag) {
125+
# if RUSTRT_TRACK_ALLOCATIONS >= 1
125126
size_t old_size = size;
127+
# endif
126128
size += HEADER_SIZE;
127129
alloc_header *mem = (alloc_header *)::malloc(size);
128130
if (mem == NULL) {
@@ -143,18 +145,9 @@ memory_region::malloc(size_t size, const char *tag, bool zero) {
143145
void *data = get_data(mem);
144146
claim_alloc(data);
145147

146-
if(zero) {
147-
memset(data, 0, old_size);
148-
}
149-
150148
return data;
151149
}
152150

153-
void *
154-
memory_region::calloc(size_t size, const char *tag) {
155-
return malloc(size, tag, true);
156-
}
157-
158151
memory_region::~memory_region() {
159152
if (_synchronized) { _lock.lock(); }
160153
if (_live_allocations == 0 && !_detailed_leaks) {

src/rt/memory_region.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ class memory_region {
7777
public:
7878
memory_region(rust_env *env, bool synchronized);
7979
memory_region(memory_region *parent);
80-
void *malloc(size_t size, const char *tag, bool zero = true);
81-
void *calloc(size_t size, const char *tag);
80+
void *malloc(size_t size, const char *tag);
8281
void *realloc(void *mem, size_t size);
8382
void free(void *mem);
8483
~memory_region();

src/rt/rust_stack.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ check_stack_canary(stk_seg *stk) {
5858
stk_seg *
5959
create_stack(memory_region *region, size_t sz) {
6060
size_t total_sz = sizeof(stk_seg) + sz;
61-
stk_seg *stk = (stk_seg *)region->malloc(total_sz, "stack", false);
61+
stk_seg *stk = (stk_seg *)region->malloc(total_sz, "stack");
6262
memset(stk, 0, sizeof(stk_seg));
6363
stk->end = (uintptr_t) &stk->data[sz];
6464
add_stack_canary(stk);

src/rt/rust_task.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,6 @@ rust_task::backtrace() {
450450
#endif
451451
}
452452

453-
void *
454-
rust_task::calloc(size_t size, const char *tag) {
455-
return local_region.calloc(size, tag);
456-
}
457-
458453
size_t
459454
rust_task::get_next_stack_size(size_t min, size_t current, size_t requested) {
460455
LOG(this, mem, "calculating new stack size for 0x%" PRIxPTR, this);

0 commit comments

Comments
 (0)