Skip to content

Commit 334333d

Browse files
author
GueLaKais
committed
Added comments to Function
To be honest, I still don't understand exactly what's happening here. All I know is that it's at least somewhat understandable what's going on here.
1 parent c642b77 commit 334333d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

rosidl_runtime_rs/src/sequence.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ macro_rules! impl_sequence_alloc_for_primitive_type {
569569
/// `true` if the sequence was successfully initialized, `false` otherwise.
570570
fn sequence_init(seq: &mut Sequence<Self>, size: usize) -> bool {
571571
// SAFETY: There are no special preconditions to the sequence_init function.
572-
573572
unsafe {
574573
if !seq.data.is_null() {
575574
// Zero memory, since it will be uninitialized if there is no default value
@@ -578,6 +577,7 @@ macro_rules! impl_sequence_alloc_for_primitive_type {
578577
$init_func(seq as *mut _, size)
579578
}
580579
}
580+
581581
/// Finalizes a sequence, freeing any associated resources.
582582
///
583583
/// # Safety
@@ -592,6 +592,22 @@ macro_rules! impl_sequence_alloc_for_primitive_type {
592592
// SAFETY: There are no special preconditions to the sequence_fini function.
593593
unsafe { $fini_func(seq as *mut _) }
594594
}
595+
596+
/// Copies the contents of one sequence to another.
597+
///
598+
/// # Safety
599+
///
600+
/// This function is unsafe because it calls an unsafe function `$copy_func`.
601+
/// The caller must ensure that `$copy_func` is safe to call with the provided arguments.
602+
///
603+
/// # Arguments
604+
///
605+
/// * `in_seq` - A reference to the sequence to be copied from.
606+
/// * `out_seq` - A mutable reference to the sequence to be copied to.
607+
///
608+
/// # Returns
609+
///
610+
/// `true` if the copy was successful, `false` otherwise.
595611
fn sequence_copy(in_seq: &Sequence<Self>, out_seq: &mut Sequence<Self>) -> bool {
596612
// SAFETY: There are no special preconditions to the sequence_copy function.
597613
unsafe { $copy_func(in_seq as *const _, out_seq as *mut _) }

0 commit comments

Comments
 (0)