diff options
author | Andrew Chow <github@achow101.com> | 2023-02-23 15:33:07 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-02-23 15:44:42 -0500 |
commit | c033720b2bc7aabf703a686e0fc024c2d25681c6 (patch) | |
tree | 775313e0fa151554d0bae4369874580fb3ede1c4 /src/support/lockedpool.h | |
parent | b7702bd546eda7d713d3aa5696af98102728113f (diff) | |
parent | f36d1d5b8934aac60d3097047ecedeb58bae2185 (diff) | |
download | bitcoin-c033720b2bc7aabf703a686e0fc024c2d25681c6.tar.xz |
Merge bitcoin/bitcoin#16195: util: Use void* throughout support/lockedpool.h
f36d1d5b8934aac60d3097047ecedeb58bae2185 Use void* throughout support/lockedpool.h (Jeffrey Czyz)
Pull request description:
Replace uses of char* with void* in Arena's member variables. Instead,
cast to char* where needed in the implementation.
Certain compiler environments disallow std::hash<char*> specializations
to prevent hashing the pointer's value instead of the string contents.
Thus, compilation fails when std::unordered_map is keyed by char*.
Explicitly using void* is a workaround in such environments. For
consistency, void* is used throughout all member variables similarly to
the public interface.
Changes to this code are covered by src/test/allocator_tests.cpp.
ACKs for top commit:
achow101:
ACK f36d1d5b8934aac60d3097047ecedeb58bae2185
theStack:
Code-review ACK f36d1d5b8934aac60d3097047ecedeb58bae2185
jonatack:
ACK f36d1d5b8934aac60d3097047ecedeb58bae2185 review, debug build, unit tests, checked clang 15 raises "error: arithmetic on a pointer to void" without the conversions here from the generic void* pointer back to char*
Tree-SHA512: f9074e6d29ef78c795a512a6e00e9b591e2ff34165d09b73eae9eef25098c59e543c194346fcd4e83185a39c430d43744b6f7f9d1728a132843c67bd27ea5189
Diffstat (limited to 'src/support/lockedpool.h')
-rw-r--r-- | src/support/lockedpool.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h index 1bba459377..81e0df513a 100644 --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -89,23 +89,23 @@ public: */ bool addressInArena(void *ptr) const { return ptr >= base && ptr < end; } private: - typedef std::multimap<size_t, char*> SizeToChunkSortedMap; + typedef std::multimap<size_t, void*> SizeToChunkSortedMap; /** Map to enable O(log(n)) best-fit allocation, as it's sorted by size */ SizeToChunkSortedMap size_to_free_chunk; - typedef std::unordered_map<char*, SizeToChunkSortedMap::const_iterator> ChunkToSizeMap; + typedef std::unordered_map<void*, SizeToChunkSortedMap::const_iterator> ChunkToSizeMap; /** Map from begin of free chunk to its node in size_to_free_chunk */ ChunkToSizeMap chunks_free; /** Map from end of free chunk to its node in size_to_free_chunk */ ChunkToSizeMap chunks_free_end; /** Map from begin of used chunk to its size */ - std::unordered_map<char*, size_t> chunks_used; + std::unordered_map<void*, size_t> chunks_used; /** Base address of arena */ - char* base; + void* base; /** End address of arena */ - char* end; + void* end; /** Minimum chunk alignment */ size_t alignment; }; |