Skip to content

Commit 325c336

Browse files
committed
Change free() to take a mutable pointer
1 parent 049e9ee commit 325c336

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rost/core2/global_heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub unsafe fn realloc_raw(ptr: *mut c_void, size: uint) -> *mut c_void {
3838
// `realloc(ptr, 0)` may allocate, but it may also return a null pointer
3939
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/realloc.html
4040
if size == 0 {
41-
free(ptr as *c_void);
41+
free(ptr);
4242
0 as *mut c_void
4343
} else {
4444
let p = realloc(ptr, size as size_t);
@@ -64,5 +64,5 @@ pub unsafe fn exchange_malloc(size: uintptr_t) -> *c_char {
6464
#[lang="exchange_free"]
6565
#[inline]
6666
pub unsafe fn exchange_free_(ptr: *c_char) {
67-
free(ptr as *c_void);
67+
free(ptr as *mut c_void);
6868
}

rost/memory/malloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ pub unsafe fn malloc(size: size_t) -> *mut c_void {
2424
pub unsafe fn realloc(p: *mut c_void, size: size_t) -> *mut c_void {
2525
let ptr = malloc(size);
2626
copy_nonoverlapping_memory(ptr, p as *c_void, size as uint);
27-
free(p as *c_void);
27+
free(p);
2828
ptr
2929
}
3030

31-
pub unsafe fn free(p: *c_void) {
31+
pub unsafe fn free(p: *mut c_void) {
3232
// Do nothing :(
3333
}

0 commit comments

Comments
 (0)