@@ -34,6 +34,9 @@ using provider_unique_handle_t =
3434#define UMF_ASSIGN_OP (ops, type, func, default_return ) \
3535 ops.func = [](void *obj, auto ... args) { \
3636 try { \
37+ if (!obj) { \
38+ return type ().func (args...); \
39+ } \
3740 return reinterpret_cast <type *>(obj)->func (args...); \
3841 } catch (...) { \
3942 return default_return; \
@@ -43,6 +46,9 @@ using provider_unique_handle_t =
4346#define UMF_ASSIGN_OP_NORETURN (ops, type, func ) \
4447 ops.func = [](void *obj, auto ... args) { \
4548 try { \
49+ if (!obj) { \
50+ return type ().func (args...); \
51+ } \
4652 return reinterpret_cast <type *>(obj)->func (args...); \
4753 } catch (...) { \
4854 } \
@@ -76,15 +82,10 @@ template <typename T> umf_memory_pool_ops_t poolOpsBase() {
7682 UMF_ASSIGN_OP (ops, T, calloc, ((void *)nullptr ));
7783 UMF_ASSIGN_OP (ops, T, aligned_malloc, ((void *)nullptr ));
7884 UMF_ASSIGN_OP (ops, T, realloc, ((void *)nullptr ));
79- UMF_ASSIGN_OP (ops, T, malloc_usable_size, UMF_RESULT_SUCCESS );
80- UMF_ASSIGN_OP (ops, T, free, UMF_RESULT_SUCCESS );
85+ UMF_ASSIGN_OP (ops, T, get_name, UMF_RESULT_ERROR_UNKNOWN );
86+ UMF_ASSIGN_OP (ops, T, malloc_usable_size, UMF_RESULT_ERROR_UNKNOWN );
87+ UMF_ASSIGN_OP (ops, T, free, UMF_RESULT_ERROR_UNKNOWN );
8188 UMF_ASSIGN_OP (ops, T, get_last_allocation_error, UMF_RESULT_ERROR_UNKNOWN );
82- ops.get_name = [](void *, const char **name) {
83- if (name) {
84- *name = " test_pool" ;
85- }
86- return UMF_RESULT_SUCCESS ;
87- };
8889 return ops;
8990}
9091
0 commit comments