@@ -1598,13 +1598,42 @@ mod unsafe {
1598
1598
:: unsafe :: reinterpret_cast( ptr:: addr_of( pair) ) ;
1599
1599
f( * v)
1600
1600
}
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
+ }
1601
1629
}
1602
1630
1603
1631
/// Operations on `[u8]`
1604
1632
mod u8 {
1605
1633
export cmp;
1606
1634
export lt, le, eq, ne, ge, gt;
1607
1635
export hash;
1636
+ export memcpy, memmove;
1608
1637
1609
1638
/// Bytewise string comparison
1610
1639
pure fn cmp( &&a: ~[ u8 ] , &&b: ~[ u8 ] ) -> int {
@@ -1655,6 +1684,32 @@ mod u8 {
1655
1684
vec:: iter( s, |c| { u *= 33 u; u += c as uint; } ) ;
1656
1685
ret u;
1657
1686
}
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
+ }
1658
1713
}
1659
1714
1660
1715
// ___________________________________________________________________________
0 commit comments