if (!m_Pool)
{
// unmanaged
- ::operator delete(m_UnmanagedMemory);
+ if (!m_Imported)
+ {
+ ::operator delete(m_UnmanagedMemory);
+ }
}
}
// Checks the 16 byte memory alignment.
if (reinterpret_cast<uint64_t>(memory) % 16)
{
+ if (m_Imported)
+ {
+ m_Imported = false;
+ m_UnmanagedMemory = nullptr;
+ }
+
return false;
}
TensorInfo info({1}, DataType::Float32);
RefTensorHandle handle(info, memoryManager, static_cast<unsigned int>(MemorySource::Malloc));
- // This pointer will be deleted in the handle destructor
int* testPtr = new int(4);
// Not supported
// Supported
BOOST_CHECK(handle.Import(static_cast<void *>(testPtr), MemorySource::Malloc));
+
+ delete testPtr;
}
BOOST_AUTO_TEST_CASE(ReusePointer)
TensorInfo info({1}, DataType::Float32);
RefTensorHandle handle(info, memoryManager, static_cast<unsigned int>(MemorySource::Malloc));
- // This pointer will be deleted in the handle destructor
int* testPtr = new int(4);
handle.Import(static_cast<void *>(testPtr), MemorySource::Malloc);
// Reusing previously Imported pointer
BOOST_CHECK(handle.Import(static_cast<void *>(testPtr), MemorySource::Malloc));
+
+ delete testPtr;
}
BOOST_AUTO_TEST_CASE(MisalignedPointer)