Skip to content

Commit 43dffc7

Browse files
committed
use unique_ptr instead of constructor/destructor in benchmarks
On Windows static builds, destructors are invoked after the UMF destructor, causing parameter structures to be unable to be destroyed. By switching to std::unique_ptr, we ensure that parameters are properly cleaned up and the destruction order issue is resolved.
1 parent 08d0dc6 commit 43dffc7

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

benchmark/benchmark.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ struct os_provider : public provider_interface {
4848

4949
// Use a lambda as the custom deleter
5050
auto deleter = [](void *p) {
51-
if (p) {
52-
auto handle =
53-
static_cast<umf_os_memory_provider_params_handle_t>(p);
54-
umfOsMemoryProviderParamsDestroy(handle);
55-
}
51+
auto handle =
52+
static_cast<umf_os_memory_provider_params_handle_t>(p);
53+
umfOsMemoryProviderParamsDestroy(handle);
5654
};
5755

5856
return {static_cast<void *>(raw_params), deleter};
@@ -120,12 +118,9 @@ struct disjoint_pool : public pool_interface<Provider> {
120118
return {nullptr, [](void *) {}};
121119
}
122120

123-
// Use a lambda as the deleter
124121
auto deleter = [](void *p) {
125-
if (p) {
126-
umfDisjointPoolParamsDestroy(
127-
static_cast<umf_disjoint_pool_params_handle_t>(p));
128-
}
122+
umfDisjointPoolParamsDestroy(
123+
static_cast<umf_disjoint_pool_params_handle_t>(p));
129124
};
130125

131126
return {static_cast<void *>(raw_params), deleter};

0 commit comments

Comments
 (0)