Commit 880e8ff9 authored by Jayaram Bobba's avatar Jayaram Bobba

Wrap default allocator in a unique pointer for automatic deallocation

parent 00f79586
......@@ -50,7 +50,11 @@ private:
AlignedBuffer(const AlignedBuffer&) = delete;
AlignedBuffer& operator=(const AlignedBuffer&) = delete;
// Allocator objects and the allocation interfaces are owned by the
// creators of AlignedBuffers. They need to ensure that the lifetime of
// m_allocator exceeds the lifetime of this AlignedBuffer.
Allocator* m_allocator;
char* m_allocated_buffer;
char* m_aligned_buffer;
size_t m_byte_size;
......
......@@ -51,6 +51,6 @@ public:
ngraph::runtime::Allocator* ngraph::runtime::get_default_allocator()
{
static DefaultAllocator* allocator = new DefaultAllocator();
return allocator;
static std::unique_ptr<DefaultAllocator> allocator(new DefaultAllocator());
return allocator.get();
}
......@@ -28,8 +28,8 @@ namespace ngraph
{
class Allocator;
class DefaultAllocator;
/// \brief Returns a statically allocated default ngraph allocator
// that calls into system allocation libraries
/// \brief Returns a pointer to a statically allocated singleton
/// allocator that calls into system allocation libraries
Allocator* get_default_allocator();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment