@@ -209,11 +209,15 @@ impl IndividualTable {
209209 /// * `Some(flags)` if `row` is valid.
210210 /// * `None` otherwise.
211211 pub fn flags < I : Into < IndividualId > + Copy > ( & self , row : I ) -> Option < IndividualFlags > {
212- sys:: tsk_column_access :: < IndividualFlags , _ , _ , _ > (
213- row. into ( ) ,
214- self . as_ref ( ) . flags ,
215- self . num_rows ( ) ,
216- )
212+ assert ! ( self . num_rows( ) == 0 || !self . as_ref( ) . flags. is_null( ) ) ;
213+ // SAFETY: either the column is empty or the point is not NULL
214+ unsafe {
215+ sys:: tsk_column_access :: < IndividualFlags , _ , _ , _ > (
216+ row. into ( ) ,
217+ self . as_ref ( ) . flags ,
218+ self . num_rows ( ) ,
219+ )
220+ }
217221 }
218222
219223 /// Return the locations for a given row.
@@ -223,13 +227,19 @@ impl IndividualTable {
223227 /// * `Some(location)` if `row` is valid.
224228 /// * `None` otherwise.
225229 pub fn location < I : Into < IndividualId > + Copy > ( & self , row : I ) -> Option < & [ Location ] > {
226- sys:: tsk_ragged_column_access (
227- row. into ( ) ,
228- self . as_ref ( ) . location ,
229- self . num_rows ( ) ,
230- self . as_ref ( ) . location_offset ,
231- self . as_ref ( ) . location_length ,
232- )
230+ assert ! (
231+ ( self . num_rows( ) == 0 && self . as_ref( ) . location_length == 0 )
232+ || ( !self . as_ref( ) . location. is_null( ) && !self . as_ref( ) . location_offset. is_null( ) )
233+ ) ;
234+ unsafe {
235+ sys:: tsk_ragged_column_access (
236+ row. into ( ) ,
237+ self . as_ref ( ) . location ,
238+ self . num_rows ( ) ,
239+ self . as_ref ( ) . location_offset ,
240+ self . as_ref ( ) . location_length ,
241+ )
242+ }
233243 }
234244
235245 /// Return the parents for a given row.
@@ -239,13 +249,19 @@ impl IndividualTable {
239249 /// * `Some(parents)` if `row` is valid.
240250 /// * `None` otherwise.
241251 pub fn parents < I : Into < IndividualId > + Copy > ( & self , row : I ) -> Option < & [ IndividualId ] > {
242- sys:: tsk_ragged_column_access (
243- row. into ( ) ,
244- self . as_ref ( ) . parents ,
245- self . num_rows ( ) ,
246- self . as_ref ( ) . parents_offset ,
247- self . as_ref ( ) . parents_length ,
248- )
252+ assert ! (
253+ ( self . num_rows( ) == 0 && self . as_ref( ) . parents_length == 0 )
254+ || ( !self . as_ref( ) . parents. is_null( ) && !self . as_ref( ) . location_offset. is_null( ) )
255+ ) ;
256+ unsafe {
257+ sys:: tsk_ragged_column_access (
258+ row. into ( ) ,
259+ self . as_ref ( ) . parents ,
260+ self . num_rows ( ) ,
261+ self . as_ref ( ) . parents_offset ,
262+ self . as_ref ( ) . parents_length ,
263+ )
264+ }
249265 }
250266
251267 /// Return the metadata for a given row.
0 commit comments