File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -655,6 +655,21 @@ pub unsafe extern "C" fn adt_first_property_offset(_dt: *const c_void, offset: c
655655 unsafe { p. sub ( adt as usize ) as c_int }
656656}
657657
658+ // This function has load-bearing UB on the C side... The sound Rust equivalent
659+ // breaks this. Recreate the UB here rather than call the new Rust function.
660+ #[ no_mangle]
661+ pub unsafe extern "C" fn adt_next_property_offset ( _dt : * const c_void , offset : c_int ) -> c_int {
662+ let ptr: usize = unsafe { adt. add ( offset as usize ) as usize } ;
663+ let p = ADTProperty :: from_ptr ( ptr) . unwrap ( ) ;
664+ unsafe {
665+ p. as_ptr ( )
666+ . add ( size_of :: < [ c_char ; 32 ] > ( ) )
667+ . add ( size_of :: < u32 > ( ) )
668+ . add ( ( p. size as usize + ( ADT_ALIGN - 1 ) ) & !( ADT_ALIGN - 1 ) )
669+ . sub ( adt as usize ) as c_int
670+ }
671+ }
672+
658673#[ no_mangle]
659674pub unsafe extern "C" fn adt_first_child_offset ( _dt : * const c_void , offset : c_int ) -> c_int {
660675 let ptr: * const ADTNode = unsafe { adt. add ( offset as usize ) as * const ADTNode } ;
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ int adt_get_property_count(const void *adt, int offset);
3232
3333int adt_first_property_offset (const void * adt , int offset );
3434
35+ int adt_next_property_offset (const void * adt , int offset );
36+
3537const struct adt_property * adt_get_property_by_offset (const void * adt , int offset );
3638
3739int adt_get_child_count (const void * adt , int offset );
You can’t perform that action at this time.
0 commit comments