Skip to content

Commit

Permalink
[#498] Adjust C API
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Nov 1, 2024
1 parent d50afad commit 4eaa0bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
28 changes: 15 additions & 13 deletions iceoryx2-ffi/ffi/src/api/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub unsafe extern "C" fn iox2_subscriber_receive(
let subscriber = &mut *subscriber_handle.as_type();

match subscriber.service_type {
iox2_service_type_e::IPC => match subscriber.value.as_ref().ipc.receive() {
iox2_service_type_e::IPC => match subscriber.value.as_ref().ipc.receive_custom_payload() {
Ok(Some(sample)) => {
let (sample_struct_ptr, deleter) = init_sample_struct_ptr(sample_struct_ptr);
(*sample_struct_ptr).init(
Expand All @@ -286,19 +286,21 @@ pub unsafe extern "C" fn iox2_subscriber_receive(
Ok(None) => (),
Err(error) => return error.into_c_int(),
},
iox2_service_type_e::LOCAL => match subscriber.value.as_ref().local.receive() {
Ok(Some(sample)) => {
let (sample_struct_ptr, deleter) = init_sample_struct_ptr(sample_struct_ptr);
(*sample_struct_ptr).init(
subscriber.service_type,
SampleUnion::new_local(sample),
deleter,
);
*sample_handle_ptr = (*sample_struct_ptr).as_handle();
iox2_service_type_e::LOCAL => {
match subscriber.value.as_ref().local.receive_custom_payload() {
Ok(Some(sample)) => {
let (sample_struct_ptr, deleter) = init_sample_struct_ptr(sample_struct_ptr);
(*sample_struct_ptr).init(
subscriber.service_type,
SampleUnion::new_local(sample),
deleter,
);
*sample_handle_ptr = (*sample_struct_ptr).as_handle();
}
Ok(None) => (),
Err(error) => return error.into_c_int(),
}
Ok(None) => (),
Err(error) => return error.into_c_int(),
},
}
}

IOX2_OK
Expand Down
5 changes: 1 addition & 4 deletions iceoryx2/src/port/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,7 @@ impl<Service: service::Service, UserHeader: Debug>
PublisherLoanError,
> {
// TypeVariant::Dynamic == slice and only here it makes sense to loan more than one element
debug_assert!(
slice_len == 1
|| (slice_len != 1 && self.payload_type_variant() == TypeVariant::Dynamic)
);
debug_assert!(slice_len == 1 || self.payload_type_variant() == TypeVariant::Dynamic);

self.loan_slice_uninit_impl(slice_len, self.payload_size * slice_len)
}
Expand Down

0 comments on commit 4eaa0bf

Please sign in to comment.