File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -93,3 +93,19 @@ pub unsafe extern "C" fn orientation_vector_from_quaternion(
93
93
let o_vec: OrientationVector = ( * quat_ptr) . into ( ) ;
94
94
to_raw_pointer ( & o_vec)
95
95
}
96
+
97
+ /// Free memory of an array of orientation vector components at the given address.
98
+ ///
99
+ /// # Safety
100
+ ///
101
+ /// Outer processes that request the components of a orientation vector should call this function
102
+ /// to free the memory allocated to the array once finished
103
+ #[ no_mangle]
104
+ pub unsafe extern "C" fn free_orientation_vector_components ( ptr : * mut c_double ) {
105
+ if ptr. is_null ( ) {
106
+ return ;
107
+ }
108
+ let slice = std:: slice:: from_raw_parts_mut ( ptr, 4 ) ;
109
+ let arr: [ c_double ; 4 ] = slice. try_into ( ) . unwrap ( ) ;
110
+ let _ = arr; // technically not necessary but helps to be explicit
111
+ }
Original file line number Diff line number Diff line change @@ -448,3 +448,19 @@ pub unsafe extern "C" fn quaternion_hamiltonian_product(
448
448
null_pointer_check ! ( quat_ptr_2) ;
449
449
to_raw_pointer ( & ( ( * quat_ptr_1) * ( * quat_ptr_2) ) )
450
450
}
451
+
452
+ /// Free memory of an array of quaternion components at the given address.
453
+ ///
454
+ /// # Safety
455
+ ///
456
+ /// Outer processes that request the components of a quaternion should call this function
457
+ /// to free the memory allocated to the array once finished
458
+ #[ no_mangle]
459
+ pub unsafe extern "C" fn free_quaternion_components ( ptr : * mut c_double ) {
460
+ if ptr. is_null ( ) {
461
+ return ;
462
+ }
463
+ let slice = std:: slice:: from_raw_parts_mut ( ptr, 4 ) ;
464
+ let arr: [ c_double ; 4 ] = slice. try_into ( ) . unwrap ( ) ;
465
+ let _ = arr; // technically not necessary but helps to be explicit
466
+ }
Original file line number Diff line number Diff line change @@ -219,3 +219,19 @@ pub unsafe extern "C" fn vector_cross_product(
219
219
let vec = ( * vec_ptr_1) . cross ( & * vec_ptr_2) ;
220
220
to_raw_pointer ( vec)
221
221
}
222
+
223
+ /// Free memory of an array of vector components at the given address.
224
+ ///
225
+ /// # Safety
226
+ ///
227
+ /// Outer processes that request the components of a vector should call this function
228
+ /// to free the memory allocated to the array once finished
229
+ #[ no_mangle]
230
+ pub unsafe extern "C" fn free_vector_components ( ptr : * mut c_double ) {
231
+ if ptr. is_null ( ) {
232
+ return ;
233
+ }
234
+ let slice = std:: slice:: from_raw_parts_mut ( ptr, 3 ) ;
235
+ let arr: [ c_double ; 3 ] = slice. try_into ( ) . unwrap ( ) ;
236
+ let _ = arr; // technically not necessary but helps to be explicit
237
+ }
You can’t perform that action at this time.
0 commit comments