Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project-vvm-async-api] Fix up #534 #535

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions crates/voicevox_core_c_api/src/slice_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ impl<T> SliceOwner<T> {
///
/// # Safety
///
/// - `out_ptr`は書き込みについて有効でなければならない(ただし`*mut T`は有効である必要は無い)。
/// - `out_len`は書き込みについて有効でなければならない。
/// - `out_ptr`は書き込みについて[有効]でなければならない。
/// - `out_len`は書き込みについて[有効]でなければならない。
///
/// [有効]: https://doc.rust-lang.org/stable/std/ptr/index.html#safety
Comment on lines +33 to +36
Copy link
Member Author

@qryxip qryxip Jul 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ついでにここも更新。

「書き込みについて有効」という言い方も微妙かもしれませんが、write_unalignedのsafetyがこうなっており、またこの言い回しについての日本語訳の先例が見当たらなかったので、これをそのまま訳す形にしました。

image

pub(crate) unsafe fn own_and_lend(
&self,
slice: impl Into<Box<[T]>>,
Expand All @@ -47,8 +49,8 @@ impl<T> SliceOwner<T> {
let duplicated = slices.insert(ptr as usize, slice.into()).is_some();
assert!(!duplicated, "duplicated");

out_ptr.as_ptr().write_volatile(ptr);
out_len.as_ptr().write_volatile(len);
out_ptr.as_ptr().write_unaligned(ptr);
out_len.as_ptr().write_unaligned(len);
}

/// `own_and_lend`でC API利用者に貸し出したポインタに対応する`Box<[u8]>`をデストラクトする。
Expand Down