Skip to content

Rename copy_overlapping_memory() to copy_memory() #4504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ use vec;
#[nolink]
#[abi = "cdecl"]
extern mod libc_ {
#[rust_stack]
unsafe fn memcpy(dest: *mut c_void,
src: *const c_void,
n: libc::size_t)
-> *c_void;

#[rust_stack]
unsafe fn memmove(dest: *mut c_void,
src: *const c_void,
Expand Down Expand Up @@ -115,27 +109,14 @@ pub pure fn is_null<T>(ptr: *const T) -> bool { ptr == null() }
#[inline(always)]
pub pure fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }

/**
* Copies data from one location to another
*
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may not overlap.
*/
#[inline(always)]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
let n = count * sys::size_of::<T>();
libc_::memcpy(dst as *mut c_void, src as *c_void, n as size_t);
}

/**
* Copies data from one location to another
*
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may overlap.
*/
#[inline(always)]
pub unsafe fn copy_overlapping_memory<T>(dst: *mut T, src: *const T,
count: uint) {
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
let n = count * sys::size_of::<T>();
libc_::memmove(dst as *mut c_void, src as *c_void, n as size_t);
}
Expand All @@ -146,7 +127,6 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: int, count: uint) {
libc_::memset(dst as *mut c_void, c as libc::c_int, n as size_t);
}


/**
Transform a region pointer - &T - to an unsafe pointer - *T.
This is safe, but is implemented with an unsafe block due to
Expand Down
32 changes: 1 addition & 31 deletions src/libcore/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2095,24 +2095,6 @@ pub mod raw {
}
}
}

/**
* Copies data from one vector to another.
*
* Copies `count` bytes from `src` to `dst`. The source and destination
* may overlap.
*/
pub unsafe fn copy_overlapping_memory<T>(dst: &[mut T], src: &[const T],
count: uint) {
assert dst.len() >= count;
assert src.len() >= count;

do as_mut_buf(dst) |p_dst, _len_dst| {
do as_const_buf(src) |p_src, _len_src| {
ptr::copy_overlapping_memory(p_dst, p_src, count)
}
}
}
}

/// Operations on `[u8]`
Expand Down Expand Up @@ -2166,24 +2148,12 @@ pub mod bytes {
* Copies data from one vector to another.
*
* Copies `count` bytes from `src` to `dst`. The source and destination
* may not overlap.
* may overlap.
*/
pub fn copy_memory(dst: &[mut u8], src: &[const u8], count: uint) {
// Bound checks are done at vec::raw::copy_memory.
unsafe { vec::raw::copy_memory(dst, src, count) }
}

/**
* Copies data from one vector to another.
*
* Copies `count` bytes from `src` to `dst`. The source and destination
* may overlap.
*/
pub fn copy_overlapping_memory(dst: &[mut u8], src: &[const u8],
count: uint) {
// Bound checks are done at vec::raw::copy_overlapping_memory.
unsafe { vec::raw::copy_overlapping_memory(dst, src, count) }
}
}

// ___________________________________________________________________________
Expand Down