junrushao commented on code in PR #593:
URL: https://github.com/apache/tvm-ffi/pull/593#discussion_r3521561236
##########
include/tvm/ffi/memory.h:
##########
@@ -168,7 +166,11 @@ class SimpleObjAllocator : public
ObjAllocatorBase<SimpleObjAllocator> {
// class with non-virtual destructor.
// We are fine here as we captured the right deleter during construction.
// This is also the right way to get storage type for an object pool.
- void* data = AlignedAlloc<alignof(T)>(sizeof(T));
+ static_assert(alignof(T) <= alignof(::std::max_align_t),
+ "Object types with alignment > max_align_t are not
supported "
+ "by the custom allocator hook");
+ TVMFFICustomAllocator* alloc = TVMFFIGetCustomAllocator();
+ void* data = alloc->allocate(sizeof(T), alignof(T),
T::RuntimeTypeIndex(), alloc->context);
new (data) T(std::forward<Args>(args)...);
Review Comment:
irrelevant but worth pointing out - please surround all `new`s with
try-catch, because it's possible that an exception occurs in constructors
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]