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

Commit 4a1026a7 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_ndk: avoid need to allocate heap status

Only allocate this once globally, since it is expected to be used on
almost every NDK-backend binder transaction.

Fixes: 167686803
Test: CtsNdkBinderTestCases
Change-Id: I1d2c5ca05a1ee6ceb5b41966e441aa51c1c315af
parent b3f953a7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -199,6 +199,9 @@ class ScopedAStatus : public impl::ScopedAResource<AStatus*, void, AStatus_delet
   public:
    /**
     * Takes ownership of a.
     *
     * WARNING: this constructor is only expected to be used when reading a
     *     status value. Use `ScopedAStatus::ok()` instead.
     */
    explicit ScopedAStatus(AStatus* a = nullptr) : ScopedAResource(a) {}
    ~ScopedAStatus() {}
+5 −2
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@ using ::android::status_t;
using ::android::binder::Status;

AStatus* AStatus_newOk() {
    return new AStatus();
    static AStatus status = AStatus();
    return &status;
}

AStatus* AStatus_fromExceptionCode(binder_exception_t exception) {
@@ -78,8 +79,10 @@ void AStatus_deleteDescription(const char* description) {
}

void AStatus_delete(AStatus* status) {
    if (status != AStatus_newOk()) {
        delete status;
    }
}

binder_status_t PruneStatusT(status_t status) {
    switch (status) {