@@ -804,41 +804,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
804
804
self . get_raw ( ptr. alloc_id ) ?. get_bytes ( self , ptr, size)
805
805
}
806
806
807
- /// Reads a 0-terminated sequence of bytes from memory. Returns them as a slice.
808
- ///
809
- /// Performs appropriate bounds checks.
810
- pub fn read_c_str ( & self , ptr : Scalar < M :: PointerTag > ) -> InterpResult < ' tcx , & [ u8 ] > {
811
- let ptr = self . force_ptr ( ptr) ?; // We need to read at least 1 byte, so we *need* a ptr.
812
- self . get_raw ( ptr. alloc_id ) ?. read_c_str ( self , ptr)
813
- }
814
-
815
- /// Reads a 0x0000-terminated u16-sequence from memory. Returns them as a Vec<u16>.
816
- /// Terminator 0x0000 is not included in the returned Vec<u16>.
817
- ///
818
- /// Performs appropriate bounds checks.
819
- pub fn read_wide_str ( & self , ptr : Scalar < M :: PointerTag > ) -> InterpResult < ' tcx , Vec < u16 > > {
820
- let size_2bytes = Size :: from_bytes ( 2 ) ;
821
- let align_2bytes = Align :: from_bytes ( 2 ) . unwrap ( ) ;
822
- // We need to read at least 2 bytes, so we *need* a ptr.
823
- let mut ptr = self . force_ptr ( ptr) ?;
824
- let allocation = self . get_raw ( ptr. alloc_id ) ?;
825
- let mut u16_seq = Vec :: new ( ) ;
826
-
827
- loop {
828
- ptr = self
829
- . check_ptr_access ( ptr. into ( ) , size_2bytes, align_2bytes) ?
830
- . expect ( "cannot be a ZST" ) ;
831
- let single_u16 = allocation. read_scalar ( self , ptr, size_2bytes) ?. to_u16 ( ) ?;
832
- if single_u16 != 0x0000 {
833
- u16_seq. push ( single_u16) ;
834
- ptr = ptr. offset ( size_2bytes, self ) ?;
835
- } else {
836
- break ;
837
- }
838
- }
839
- Ok ( u16_seq)
840
- }
841
-
842
807
/// Writes the given stream of bytes into memory.
843
808
///
844
809
/// Performs appropriate bounds checks.
@@ -866,46 +831,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
866
831
self . get_raw_mut ( ptr. alloc_id ) ?. write_bytes ( & tcx, ptr, src)
867
832
}
868
833
869
- /// Writes the given stream of u16s into memory.
870
- ///
871
- /// Performs appropriate bounds checks.
872
- pub fn write_u16s (
873
- & mut self ,
874
- ptr : Scalar < M :: PointerTag > ,
875
- src : impl IntoIterator < Item = u16 > ,
876
- ) -> InterpResult < ' tcx > {
877
- let mut src = src. into_iter ( ) ;
878
- let ( lower, upper) = src. size_hint ( ) ;
879
- let len = upper. expect ( "can only write bounded iterators" ) ;
880
- assert_eq ! ( lower, len, "can only write iterators with a precise length" ) ;
881
-
882
- let size = Size :: from_bytes ( lower) ;
883
- let ptr = match self . check_ptr_access ( ptr, size, Align :: from_bytes ( 2 ) . unwrap ( ) ) ? {
884
- Some ( ptr) => ptr,
885
- None => {
886
- // zero-sized access
887
- assert_matches ! (
888
- src. next( ) ,
889
- None ,
890
- "iterator said it was empty but returned an element"
891
- ) ;
892
- return Ok ( ( ) ) ;
893
- }
894
- } ;
895
- let tcx = self . tcx ;
896
- let allocation = self . get_raw_mut ( ptr. alloc_id ) ?;
897
-
898
- for idx in 0 ..len {
899
- let val = Scalar :: from_u16 (
900
- src. next ( ) . expect ( "iterator was shorter than it said it would be" ) ,
901
- ) ;
902
- let offset_ptr = ptr. offset ( Size :: from_bytes ( idx) * 2 , & tcx) ?; // `Size` multiplication
903
- allocation. write_scalar ( & tcx, offset_ptr, val. into ( ) , Size :: from_bytes ( 2 ) ) ?;
904
- }
905
- assert_matches ! ( src. next( ) , None , "iterator was longer than it said it would be" ) ;
906
- Ok ( ( ) )
907
- }
908
-
909
834
/// Expects the caller to have checked bounds and alignment.
910
835
pub fn copy (
911
836
& mut self ,
0 commit comments