Skip to content

Commit 9cafb27

Browse files
committed
docs: safety comments on more FFI functions
1 parent 021e4e8 commit 9cafb27

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

datadog-profiling-ffi/src/profiles/datatypes.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,11 @@ pub unsafe extern "C" fn ddog_prof_Profile_new(
419419
profile_new(sample_types, period, None)
420420
}
421421

422-
/// Same as `ddog_profile_new` but also configures a `string_storage` for the profile.
422+
/// Same as [ddog_prof_Profile_new] but also configures a `string_storage` for
423+
/// the profile.
424+
///
425+
/// # Safety
426+
/// Has all same safety conditions as [ddog_prof_Profile_new].
423427
#[no_mangle]
424428
#[must_use]
425429
/// TODO: @ivoanjo Should this take a `*mut ManagedStringStorage` like Profile APIs do?
@@ -809,6 +813,14 @@ pub unsafe extern "C" fn ddog_prof_Profile_serialize(
809813
.into()
810814
}
811815

816+
/// Borrows FFI Vec as an FFI Slice.
817+
///
818+
/// # Safety
819+
/// The input needs to be a valid reference to an FFI Vec, and the slice needs
820+
/// to be used in a way consistent with the lifetime and safety rules. Some
821+
/// things to avoid:
822+
/// - Do not modify the Vec at all while the Slice is alive.
823+
/// - Do not drop the Vec while the Slice is alive.
812824
#[must_use]
813825
#[no_mangle]
814826
pub unsafe extern "C" fn ddog_Vec_U8_as_slice(vec: &ddcommon_ffi::Vec<u8>) -> Slice<u8> {

datadog-profiling-ffi/src/profiles/interning_api.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,9 @@ pub unsafe extern "C" fn ddog_prof_Profile_get_generation(
407407
}
408408

409409
/// This functions returns whether the given generations are equal.
410-
///
411-
/// # Safety: No safety requirements
412410
#[must_use]
413411
#[no_mangle]
414-
pub unsafe extern "C" fn ddog_prof_Profile_generations_are_equal(
415-
a: Generation,
416-
b: Generation,
417-
) -> bool {
412+
pub extern "C" fn ddog_prof_Profile_generations_are_equal(a: Generation, b: Generation) -> bool {
418413
a == b
419414
}
420415

0 commit comments

Comments
 (0)