We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
min(new_size, old_size)
1 parent b0b4851 commit b1f7d3aCopy full SHA for b1f7d3a
src/liballoc/heap.rs
@@ -208,6 +208,7 @@ mod imp {
208
209
#[cfg(not(jemalloc), unix)]
210
mod imp {
211
+ use core::cmp;
212
use core::mem;
213
use core::ptr;
214
use libc;
@@ -248,7 +249,7 @@ mod imp {
248
249
pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint,
250
old_size: uint) -> *mut u8 {
251
let new_ptr = allocate(size, align);
- ptr::copy_memory(new_ptr, ptr as *const u8, old_size);
252
+ ptr::copy_memory(new_ptr, ptr as *const u8, cmp::min(size, old_size));
253
deallocate(ptr, old_size, align);
254
return new_ptr;
255
}
0 commit comments