Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 828dc104 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Use usize instead of c_long in Rust code" am: d431b2e0 am: 522a9f77 am: 65f19923

parents e2d63209 65f19923
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ use crate::sys;
use std::convert::{TryFrom, TryInto};
use std::ffi::c_void;
use std::mem::{self, ManuallyDrop, MaybeUninit};
use std::os::raw::{c_char, c_ulong};
use std::os::raw::c_char;
use std::ptr;
use std::slice;

@@ -103,12 +103,8 @@ pub trait SerializeArray: Serialize + Sized {
unsafe extern "C" fn serialize_element<T: Serialize>(
    parcel: *mut sys::AParcel,
    array: *const c_void,
    index: c_ulong,
    index: usize,
) -> status_t {
    // c_ulong and usize are the same, but we need the explicitly sized version
    // so the function signature matches what bindgen generates.
    let index = index as usize;

    let slice: &[T] = slice::from_raw_parts(array.cast(), index + 1);

    let mut parcel = match BorrowedParcel::from_raw(parcel) {
@@ -158,12 +154,8 @@ pub trait DeserializeArray: Deserialize {
unsafe extern "C" fn deserialize_element<T: Deserialize>(
    parcel: *const sys::AParcel,
    array: *mut c_void,
    index: c_ulong,
    index: usize,
) -> status_t {
    // c_ulong and usize are the same, but we need the explicitly sized version
    // so the function signature matches what bindgen generates.
    let index = index as usize;

    let vec = &mut *(array as *mut Option<Vec<MaybeUninit<T>>>);
    let vec = match vec {
        Some(v) => v,