mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
Fix block_pool_resource allocation and deallocation
This commit is contained in:
parent
de80de3828
commit
01bbcf7dca
@ -107,16 +107,20 @@ public:
|
||||
}
|
||||
auto &map = get_block_pool_map();
|
||||
auto it = map.find(r_size);
|
||||
if ((it == map.end()) || (it->second == nullptr)) LIBIMP_TRY {
|
||||
if ((it == map.end()) || (it->second == nullptr)) {
|
||||
block_pool_resource<0, 0> *bp = nullptr;
|
||||
LIBIMP_TRY {
|
||||
// If the corresponding memory resource cannot be found,
|
||||
// create a temporary general-purpose block pool to deallocate memory.
|
||||
it = map.emplace(r_size, new block_pool_resource<0, 0>).first;
|
||||
it = map.emplace(r_size, bp = new block_pool_resource<0, 0>).first;
|
||||
} LIBIMP_CATCH(...) {
|
||||
// If the memory resource cannot be created,
|
||||
// store the pointer directly to avoid leakage.
|
||||
delete bp;
|
||||
base_t::deallocate(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
it->second->deallocate(p);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user