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

Mangle rust buffer functions #1718

Closed
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
15 changes: 4 additions & 11 deletions uniffi_core/src/ffi/rustbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,7 @@ impl Default for RustBuffer {
/// to the foreign-language code as a `RustBuffer` struct. Callers must eventually
/// free the resulting buffer, either by explicitly calling [`uniffi_rustbuffer_free`] defined
/// below, or by passing ownership of the buffer back into Rust code.
#[no_mangle]
pub extern "C" fn uniffi_rustbuffer_alloc(
size: i32,
call_status: &mut RustCallStatus,
) -> RustBuffer {
pub fn uniffi_rustbuffer_alloc(size: i32, call_status: &mut RustCallStatus) -> RustBuffer {
rust_call(call_status, || {
Ok(RustBuffer::new_with_size(size.max(0) as usize))
})
Expand All @@ -225,8 +221,7 @@ pub extern "C" fn uniffi_rustbuffer_alloc(
/// # Safety
/// This function will dereference a provided pointer in order to copy bytes from it, so
/// make sure the `ForeignBytes` struct contains a valid pointer and length.
#[no_mangle]
pub unsafe extern "C" fn uniffi_rustbuffer_from_bytes(
pub fn uniffi_rustbuffer_from_bytes(
bytes: ForeignBytes,
call_status: &mut RustCallStatus,
) -> RustBuffer {
Expand All @@ -242,8 +237,7 @@ pub unsafe extern "C" fn uniffi_rustbuffer_from_bytes(
/// The argument *must* be a uniquely-owned `RustBuffer` previously obtained from a call
/// into the Rust code that returned a buffer, or you'll risk freeing unowned memory or
/// corrupting the allocator state.
#[no_mangle]
pub unsafe extern "C" fn uniffi_rustbuffer_free(buf: RustBuffer, call_status: &mut RustCallStatus) {
pub fn uniffi_rustbuffer_free(buf: RustBuffer, call_status: &mut RustCallStatus) {
rust_call(call_status, || {
RustBuffer::destroy(buf);
Ok(())
Expand All @@ -265,8 +259,7 @@ pub unsafe extern "C" fn uniffi_rustbuffer_free(buf: RustBuffer, call_status: &m
/// The first argument *must* be a uniquely-owned `RustBuffer` previously obtained from a call
/// into the Rust code that returned a buffer, or you'll risk freeing unowned memory or
/// corrupting the allocator state.
#[no_mangle]
pub unsafe extern "C" fn uniffi_rustbuffer_reserve(
pub fn uniffi_rustbuffer_reserve(
buf: RustBuffer,
additional: i32,
call_status: &mut RustCallStatus,
Expand Down