From df3103622b7de05f4e35b22a2c94b4a46eab4efc Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 14 Nov 2018 13:16:56 +0000 Subject: COMPMID-1088: Use IMemoryRegion in interfaces where possible -Simplifies import memory interface -Changes the used of void** handles with appropriate interfaces. Change-Id: I5918c855c11f46352058864623336b352162a4b7 --- src/runtime/OffsetMemoryPool.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/runtime/OffsetMemoryPool.cpp') diff --git a/src/runtime/OffsetMemoryPool.cpp b/src/runtime/OffsetMemoryPool.cpp index 96f54f890f..36eaf0ba1a 100644 --- a/src/runtime/OffsetMemoryPool.cpp +++ b/src/runtime/OffsetMemoryPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -28,6 +28,7 @@ #include "arm_compute/core/Error.h" #include "arm_compute/runtime/IAllocator.h" #include "arm_compute/runtime/IMemoryPool.h" +#include "arm_compute/runtime/MemoryRegion.h" #include "arm_compute/runtime/Types.h" #include "support/ToolchainSupport.h" @@ -37,14 +38,7 @@ OffsetMemoryPool::OffsetMemoryPool(IAllocator *allocator, size_t blob_size) : _allocator(allocator), _blob(), _blob_size(blob_size) { ARM_COMPUTE_ERROR_ON(!allocator); - _blob = _allocator->allocate(_blob_size, 0); -} - -OffsetMemoryPool::~OffsetMemoryPool() -{ - ARM_COMPUTE_ERROR_ON(!_allocator); - _allocator->free(_blob); - _blob = nullptr; + _blob = _allocator->make_region(blob_size, 0); } void OffsetMemoryPool::acquire(MemoryMappings &handles) @@ -55,7 +49,7 @@ void OffsetMemoryPool::acquire(MemoryMappings &handles) for(auto &handle : handles) { ARM_COMPUTE_ERROR_ON(handle.first == nullptr); - *handle.first = reinterpret_cast(_blob) + handle.second; + handle.first->set_owned_region(_blob->extract_subregion(handle.second, _blob_size - handle.second)); } } @@ -64,7 +58,7 @@ void OffsetMemoryPool::release(MemoryMappings &handles) for(auto &handle : handles) { ARM_COMPUTE_ERROR_ON(handle.first == nullptr); - *handle.first = nullptr; + handle.first->set_region(nullptr); } } -- cgit v1.2.1