aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/OffsetMemoryPool.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-11-14 13:16:56 +0000
committerIsabella Gottardi <isabella.gottardi@arm.com>2018-11-21 09:52:04 +0000
commitdf3103622b7de05f4e35b22a2c94b4a46eab4efc (patch)
tree17e10253e7a069c69d10bea0882b699b99d74b86 /src/runtime/OffsetMemoryPool.cpp
parentc47ef20d69e8ea0f519fdc679435cd7037fc18fe (diff)
downloadComputeLibrary-df3103622b7de05f4e35b22a2c94b4a46eab4efc.tar.gz
COMPMID-1088: Use IMemoryRegion in interfaces where possible
-Simplifies import memory interface -Changes the used of void** handles with appropriate interfaces. Change-Id: I5918c855c11f46352058864623336b352162a4b7
Diffstat (limited to 'src/runtime/OffsetMemoryPool.cpp')
-rw-r--r--src/runtime/OffsetMemoryPool.cpp16
1 files changed, 5 insertions, 11 deletions
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<uint8_t *>(_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);
}
}