@@ -30,7 +30,7 @@ constexpr inline std::size_t regular_level(std::size_t s) noexcept {
30
30
31
31
constexpr inline std::size_t regular_sizeof_impl (std::size_t l, std::size_t s) noexcept {
32
32
return (l == 0 ) ? std::max<std::size_t >(::LIBIMP::round_up<std::size_t >(s, 8 ), regular_head_size) :
33
- (l == 1 ) ? ::LIBIMP::round_up<std::size_t >(s, 128 ) :
33
+ (l == 1 ) ? ::LIBIMP::round_up<std::size_t >(s, 128 ) :
34
34
(l == 2 ) ? ::LIBIMP::round_up<std::size_t >(s, 1024 ) :
35
35
(l == 3 ) ? ::LIBIMP::round_up<std::size_t >(s, 8192 ) : (std::numeric_limits<std::size_t >::max)();
36
36
}
@@ -107,15 +107,19 @@ class block_pool_resource : public block_pool<BlockSize, BlockPoolExpansion>
107
107
}
108
108
auto &map = get_block_pool_map ();
109
109
auto it = map.find (r_size);
110
- if ((it == map.end ()) || (it->second == nullptr )) LIBIMP_TRY {
111
- // If the corresponding memory resource cannot be found,
112
- // create a temporary general-purpose block pool to deallocate memory.
113
- it = map.emplace (r_size, new block_pool_resource<0 , 0 >).first ;
114
- } LIBIMP_CATCH (...) {
115
- // If the memory resource cannot be created,
116
- // store the pointer directly to avoid leakage.
117
- base_t::deallocate (p);
118
- return ;
110
+ if ((it == map.end ()) || (it->second == nullptr )) {
111
+ block_pool_resource<0 , 0 > *bp = nullptr ;
112
+ LIBIMP_TRY {
113
+ // If the corresponding memory resource cannot be found,
114
+ // create a temporary general-purpose block pool to deallocate memory.
115
+ it = map.emplace (r_size, bp = new block_pool_resource<0 , 0 >).first ;
116
+ } LIBIMP_CATCH (...) {
117
+ // If the memory resource cannot be created,
118
+ // store the pointer directly to avoid leakage.
119
+ delete bp;
120
+ base_t::deallocate (p);
121
+ return ;
122
+ }
119
123
}
120
124
it->second ->deallocate (p);
121
125
}
0 commit comments