Skip to content

Commit 3da5d3f

Browse files
ericktgraydon
authored andcommitted
---
yaml --- r: 22676 b: refs/heads/master c: 971b591 h: refs/heads/master v: v3
1 parent 575c417 commit 3da5d3f

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9d4aab80a718a84a03c379e98a7a4f812822e347
2+
refs/heads/master: 971b59106a240b63a43fed4775d8cf0a3883f406
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/vec.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,13 +1598,42 @@ mod unsafe {
15981598
::unsafe::reinterpret_cast(ptr::addr_of(pair));
15991599
f(*v)
16001600
}
1601+
1602+
/**
1603+
* Copies data from one vector to another.
1604+
*
1605+
* Copies `count` bytes from `src` to `dst`. The source and destination
1606+
* may overlap.
1607+
*/
1608+
unsafe fn memcpy<T>(dst: &[mut T], src: &[const T], count: uint) {
1609+
do unpack_slice(dst) |p_dst, _len_dst| {
1610+
do unpack_slice(src) |p_src, _len_src| {
1611+
ptr::memcpy(p_dst, p_src, count)
1612+
}
1613+
}
1614+
}
1615+
1616+
/**
1617+
* Copies data from one vector to another.
1618+
*
1619+
* Copies `count` bytes from `src` to `dst`. The source and destination
1620+
* may overlap.
1621+
*/
1622+
unsafe fn memmove<T>(dst: &[mut T], src: &[const T], count: uint) {
1623+
do unpack_slice(dst) |p_dst, _len_dst| {
1624+
do unpack_slice(src) |p_src, _len_src| {
1625+
ptr::memmove(p_dst, p_src, count)
1626+
}
1627+
}
1628+
}
16011629
}
16021630

16031631
/// Operations on `[u8]`
16041632
mod u8 {
16051633
export cmp;
16061634
export lt, le, eq, ne, ge, gt;
16071635
export hash;
1636+
export memcpy, memmove;
16081637

16091638
/// Bytewise string comparison
16101639
pure fn cmp(&&a: ~[u8], &&b: ~[u8]) -> int {
@@ -1655,6 +1684,32 @@ mod u8 {
16551684
vec::iter(s, |c| {u *= 33u; u += c as uint;});
16561685
ret u;
16571686
}
1687+
1688+
/**
1689+
* Copies data from one vector to another.
1690+
*
1691+
* Copies `count` bytes from `src` to `dst`. The source and destination
1692+
* may not overlap.
1693+
*/
1694+
fn memcpy(dst: &[mut u8], src: &[const u8], count: uint) {
1695+
assert dst.len() >= count;
1696+
assert src.len() >= count;
1697+
1698+
unsafe { vec::unsafe::memcpy(dst, src, count) }
1699+
}
1700+
1701+
/**
1702+
* Copies data from one vector to another.
1703+
*
1704+
* Copies `count` bytes from `src` to `dst`. The source and destination
1705+
* may overlap.
1706+
*/
1707+
fn memmove(dst: &[mut u8], src: &[const u8], count: uint) {
1708+
assert dst.len() >= count;
1709+
assert src.len() >= count;
1710+
1711+
unsafe { vec::unsafe::memmove(dst, src, count) }
1712+
}
16581713
}
16591714

16601715
// ___________________________________________________________________________

0 commit comments

Comments
 (0)