File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
Expand file tree Collapse file tree 3 files changed +46
-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(
9393 let o_vec: OrientationVector = ( * quat_ptr) . into ( ) ;
9494 to_raw_pointer ( & o_vec)
9595}
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+
109+ let ptr = ptr as * mut [ c_double ; 4 ] ;
110+ let _: Box < [ c_double ; 4 ] > = Box :: from_raw ( ptr) ;
111+ }
Original file line number Diff line number Diff line change @@ -448,3 +448,18 @@ pub unsafe extern "C" fn quaternion_hamiltonian_product(
448448 null_pointer_check ! ( quat_ptr_2) ;
449449 to_raw_pointer ( & ( ( * quat_ptr_1) * ( * quat_ptr_2) ) )
450450}
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 ptr = ptr as * mut [ c_double ; 4 ] ;
464+ let _: Box < [ c_double ; 4 ] > = Box :: from_raw ( ptr) ;
465+ }
Original file line number Diff line number Diff line change @@ -219,3 +219,18 @@ pub unsafe extern "C" fn vector_cross_product(
219219 let vec = ( * vec_ptr_1) . cross ( & * vec_ptr_2) ;
220220 to_raw_pointer ( vec)
221221}
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 ptr = ptr as * mut [ c_double ; 3 ] ;
235+ let _: Box < [ c_double ; 3 ] > = Box :: from_raw ( ptr) ;
236+ }
You can’t perform that action at this time.
0 commit comments