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

Commit 90b16fbd authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: add ABuffer.CreateAsCopy

Bug: 10706245
Change-Id: I8c4e96a2581a039e9e8237c3e09e2c22226da055
parent d8f33e78
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ struct ABuffer : public RefBase {

    void setRange(size_t offset, size_t size);

    // create buffer from dup of some memory block
    static sp<ABuffer> CreateAsCopy(const void *data, size_t capacity);

    void setInt32Data(int32_t data) { mInt32Data = data; }
    int32_t int32Data() const { return mInt32Data; }

+8 −0
Original line number Diff line number Diff line
@@ -40,6 +40,14 @@ ABuffer::ABuffer(void *data, size_t capacity)
      mOwnsData(false) {
}

// static
sp<ABuffer> ABuffer::CreateAsCopy(const void *data, size_t capacity)
{
    sp<ABuffer> res = new ABuffer(capacity);
    memcpy(res->data(), data, capacity);
    return res;
}

ABuffer::~ABuffer() {
    if (mOwnsData) {
        if (mData != NULL) {