@@ -13,18 +13,6 @@ unsafe fn copy_bitstream_from_rust_to_c(
13
13
bitstream_ptr : * mut bitstream ,
14
14
rust_bitstream : & BitStreamRust ,
15
15
) {
16
- // Handle empty slice case
17
- if rust_bitstream. data . is_empty ( ) {
18
- ( * bitstream_ptr) . pos = std:: ptr:: null_mut ( ) ;
19
- ( * bitstream_ptr) . bpos = 8 ;
20
- ( * bitstream_ptr) . end = std:: ptr:: null_mut ( ) ;
21
- ( * bitstream_ptr) . bitsleft = 0 ;
22
- ( * bitstream_ptr) . error = c_int:: from ( rust_bitstream. error ) ;
23
- ( * bitstream_ptr) . _i_pos = std:: ptr:: null_mut ( ) ;
24
- ( * bitstream_ptr) . _i_bpos = 0 ;
25
- return ;
26
- }
27
-
28
16
// Get the original pos (which is the base of our slice)
29
17
let base_ptr = rust_bitstream. data . as_ptr ( ) as * mut c_uchar ;
30
18
let end_ptr = base_ptr. add ( rust_bitstream. data . len ( ) ) ;
@@ -63,19 +51,15 @@ unsafe fn copy_bitstream_c_to_rust(value: *mut bitstream) -> BitStreamRust<'stat
63
51
// Calculate total buffer length from pos to end
64
52
let total_len = ( * value) . end . offset_from ( ( * value) . pos ) as usize ;
65
53
66
- if total_len > 0 {
67
- // Create slice from current position to end
68
- slice = std:: slice:: from_raw_parts ( ( * value) . pos , total_len) ;
69
- // Current position in this slice is 0 (since slice starts from current pos)
70
- current_pos_in_slice = 0 ;
54
+ // Create slice from current position to end
55
+ slice = std:: slice:: from_raw_parts ( ( * value) . pos , total_len) ;
56
+ // Current position in this slice is 0 (since slice starts from current pos)
57
+ current_pos_in_slice = 0 ;
71
58
72
- // Calculate _i_pos relative to the slice start (which is current pos)
73
- if !( * value) . _i_pos . is_null ( ) {
74
- let i_offset = ( * value) . _i_pos . offset_from ( ( * value) . pos ) ;
75
- i_pos_in_slice = i_offset. max ( 0 ) as usize ;
76
- }
77
- } else if ( * value) . pos == ( * value) . end {
78
- slice = std:: slice:: from_raw_parts ( ( * value) . pos , 1 ) ;
59
+ // Calculate _i_pos relative to the slice start (which is current pos)
60
+ if !( * value) . _i_pos . is_null ( ) {
61
+ let i_offset = ( * value) . _i_pos . offset_from ( ( * value) . pos ) ;
62
+ i_pos_in_slice = i_offset. max ( 0 ) as usize ;
79
63
}
80
64
}
81
65
0 commit comments