Skip to content

Commit cff218e

Browse files
authored
fix: vx_struct_fields_field_dtype takes usize instead of u64 (#5396)
fix #5391 Signed-off-by: Robert Kruszewski <[email protected]>
1 parent dc03c4f commit cff218e

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

vortex-ffi/cinclude/vortex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ const vx_string *vx_struct_fields_field_name(const vx_struct_fields *dtype, size
805805
*
806806
* Returns null if the index is out of bounds or if the field dtype cannot be parsed.
807807
*/
808-
const vx_dtype *vx_struct_fields_field_dtype(const vx_struct_fields *dtype, uint64_t idx);
808+
const vx_dtype *vx_struct_fields_field_dtype(const vx_struct_fields *dtype, size_t idx);
809809

810810
/**
811811
* Free an owned [`vx_struct_fields_builder`] object.

vortex-ffi/src/struct_fields.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,16 @@ pub unsafe extern "C-unwind" fn vx_struct_fields_field_name(
5656
#[unsafe(no_mangle)]
5757
pub unsafe extern "C-unwind" fn vx_struct_fields_field_dtype(
5858
dtype: *const vx_struct_fields,
59-
idx: u64,
59+
idx: usize,
6060
) -> *const vx_dtype {
6161
let ptr = unsafe { dtype.as_ref() }.vortex_expect("null ptr");
6262
let struct_dtype = &ptr.0;
6363

64-
let idx_usize = match usize::try_from(idx) {
65-
Ok(i) => i,
66-
Err(_) => return ptr::null(),
67-
};
68-
69-
if idx_usize >= struct_dtype.nfields() {
64+
if idx >= struct_dtype.nfields() {
7065
return ptr::null();
7166
}
7267

73-
match struct_dtype.field_by_index(idx_usize) {
68+
match struct_dtype.field_by_index(idx) {
7469
Some(field_dtype) => vx_dtype::new(Arc::new(field_dtype)),
7570
None => ptr::null(),
7671
}

0 commit comments

Comments
 (0)