@@ -137,6 +137,19 @@ pub unsafe fn tsk_column_access<
137137 tsk_column_access_detail ( row, column, column_length) . map ( |v| v. into ( ) )
138138}
139139
140+ /// # SAFETY
141+ ///
142+ /// The safety requirements here are a bit fiddly.
143+ ///
144+ /// The hard case is when the columns contain data:
145+ ///
146+ /// * column and offset must both not be NULL
147+ /// * column_length and offset_length must both be
148+ /// the correct lengths for the input pointers
149+ /// * we return None if row < 0 or row > array length.
150+ ///
151+ /// When the lengths of each column are 0, we
152+ /// don't worry about anything else
140153unsafe fn tsk_ragged_column_access_detail <
141154 R : Into < bindings:: tsk_id_t > ,
142155 L : Into < bindings:: tsk_size_t > ,
@@ -175,6 +188,7 @@ unsafe fn tsk_ragged_column_access_detail<
175188 }
176189}
177190
191+ // SAFETY: see tsk_ragged_column_access_detail
178192pub unsafe fn tsk_ragged_column_access <
179193 ' a ,
180194 O ,
@@ -188,9 +202,12 @@ pub unsafe fn tsk_ragged_column_access<
188202 offset : * const bindings:: tsk_size_t ,
189203 offset_length : bindings:: tsk_size_t ,
190204) -> Option < & ' a [ O ] > {
191- // SAFETY: see tsk_ragged_column_access_detail
192- tsk_ragged_column_access_detail ( row, column, column_length, offset, offset_length)
193- . map ( |( p, n) | unsafe { std:: slice:: from_raw_parts ( p. cast :: < O > ( ) , n) } )
205+ unsafe {
206+ tsk_ragged_column_access_detail ( row, column, column_length, offset, offset_length)
207+ // If the safety requirements of tsk_ragged_column_access_detail are upheld,
208+ // then we have received a valid pointer + length from which to make a slice
209+ . map ( |( p, n) | std:: slice:: from_raw_parts ( p. cast :: < O > ( ) , n) )
210+ }
194211}
195212
196213/// # SAFETY
0 commit comments