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

Commit 5a3a2312 authored by Steven Moreland's avatar Steven Moreland Committed by android-build-merger
Browse files

Merge changes from topic "binder-primitive-array" am: d88ac7f7 am: 3466efff

am: 595549ee

Change-Id: Iea7b8c8cd2247e1cb017d50b98669e613f75a13f
parents 1a06c793 595549ee
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -136,12 +136,12 @@ typedef int8_t* (*AParcel_byteArrayGetter)(void* arrayData);
 *
 * If allocation fails, null should be returned.
 */
typedef void* (*AParcel_string_reallocator)(void* stringData, size_t length);
typedef void* (*AParcel_stringReallocator)(void* stringData, size_t length);

/**
 * This is called to get the buffer from a stringData object.
 */
typedef char* (*AParcel_string_getter)(void* stringData);
typedef char* (*AParcel_stringGetter)(void* stringData);

/**
 * Writes an AIBinder to the next location in a non-null parcel. Can be null.
@@ -198,8 +198,8 @@ binder_status_t AParcel_writeString(AParcel* parcel, const char* string, size_t
 * If this function returns a success, the buffer returned by allocator when passed stringData will
 * contain a null-terminated c-str read from the binder.
 */
binder_status_t AParcel_readString(const AParcel* parcel, AParcel_string_reallocator reallocator,
                                   AParcel_string_getter getter, void** stringData)
binder_status_t AParcel_readString(const AParcel* parcel, AParcel_stringReallocator reallocator,
                                   AParcel_stringGetter getter, void** stringData)
        __INTRODUCED_IN(29);

// @START-PRIMITIVE-READ-WRITE
+3 −3
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ inline binder_status_t AParcel_readVector<int8_t>(const AParcel* parcel, std::ve
 * Takes a std::string and reallocates it to the specified length. For use with AParcel_readString.
 * See use below in AParcel_readString.
 */
static inline void* AParcel_std_string_reallocator(void* stringData, size_t length) {
static inline void* AParcel_stdStringReallocator(void* stringData, size_t length) {
    std::string* str = static_cast<std::string*>(stringData);
    str->resize(length - 1);
    return stringData;
@@ -279,7 +279,7 @@ static inline void* AParcel_std_string_reallocator(void* stringData, size_t leng
/**
 * Takes a std::string and returns the inner char*.
 */
static inline char* AParcel_std_string_getter(void* stringData) {
static inline char* AParcel_stdStringGetter(void* stringData) {
    std::string* str = static_cast<std::string*>(stringData);
    return &(*str)[0];
}
@@ -296,7 +296,7 @@ static inline binder_status_t AParcel_writeString(AParcel* parcel, const std::st
 */
static inline binder_status_t AParcel_readString(const AParcel* parcel, std::string* str) {
    void* stringData = static_cast<void*>(str);
    return AParcel_readString(parcel, AParcel_std_string_reallocator, AParcel_std_string_getter,
    return AParcel_readString(parcel, AParcel_stdStringReallocator, AParcel_stdStringGetter,
                              &stringData);
}

+3 −3
Original line number Diff line number Diff line
@@ -255,8 +255,8 @@ binder_status_t AParcel_writeString(AParcel* parcel, const char* string, size_t
    return STATUS_OK;
}

binder_status_t AParcel_readString(const AParcel* parcel, AParcel_string_reallocator reallocator,
                                   AParcel_string_getter getter, void** stringData) {
binder_status_t AParcel_readString(const AParcel* parcel, AParcel_stringReallocator reallocator,
                                   AParcel_stringGetter getter, void** stringData) {
    size_t len16;
    const char16_t* str16 = parcel->get()->readString16Inplace(&len16);

@@ -287,7 +287,7 @@ binder_status_t AParcel_readString(const AParcel* parcel, AParcel_string_realloc
    char* str8 = getter(*stringData);

    if (str8 == nullptr) {
        LOG(WARNING) << __func__ << ": AParcel_string_allocator failed to allocate.";
        LOG(WARNING) << __func__ << ": AParcel_stringReallocator failed to allocate.";
        return STATUS_NO_MEMORY;
    }