@@ -42,8 +42,8 @@ const BUF_SIZE_LIMIT: usize = 1024 * 1024;
42
42
// frame per table entry in 30 fps.
43
43
const TABLE_SIZE_LIMIT : u32 = 30 * 60 * 60 * 24 * 7 ;
44
44
45
- // TODO: vec_push() and vec_reserve() needs to be replaced when Rust supports
46
- // fallible memory allocation in raw_vec.
45
+ // TODO: vec_push() needs to be replaced when Rust supports fallible memory
46
+ // allocation in raw_vec.
47
47
#[ allow( unreachable_code) ]
48
48
pub fn vec_push < T > ( vec : & mut Vec < T > , val : T ) -> std:: result:: Result < ( ) , ( ) > {
49
49
#[ cfg( feature = "mp4parse_fallible" ) ]
@@ -55,24 +55,13 @@ pub fn vec_push<T>(vec: &mut Vec<T>, val: T) -> std::result::Result<(), ()> {
55
55
Ok ( ( ) )
56
56
}
57
57
58
- #[ allow( unreachable_code) ]
59
- pub fn vec_reserve < T > ( vec : & mut Vec < T > , size : usize ) -> std:: result:: Result < ( ) , ( ) > {
60
- #[ cfg( feature = "mp4parse_fallible" ) ]
61
- {
62
- return FallibleVec :: try_reserve ( vec, size) ;
63
- }
64
-
65
- vec. reserve ( size) ;
66
- Ok ( ( ) )
67
- }
68
-
69
58
#[ allow( unreachable_code) ]
70
59
fn allocate_read_buf ( size : usize ) -> std:: result:: Result < Vec < u8 > , ( ) > {
71
60
#[ cfg( feature = "mp4parse_fallible" ) ]
72
61
{
73
62
let mut buf: Vec < u8 > = Vec :: new ( ) ;
74
63
FallibleVec :: try_reserve ( & mut buf, size) ?;
75
- unsafe { buf. set_len ( size) ; }
64
+ buf. extend ( std :: iter :: repeat ( 0 ) . take ( size) ) ;
76
65
return Ok ( buf) ;
77
66
}
78
67
0 commit comments