RFR: 8345314: Add a red–black tree as a utility data structure [v7]

Casper Norrbin cnorrbin at openjdk.org
Thu Jan 9 13:17:42 UTC 2025


On Wed, 8 Jan 2025 11:02:00 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> src/hotspot/share/utilities/rbTree.hpp line 308:
>> 
>>> 306: 
>>> 307:   void free(void* ptr) { os::free(ptr); }
>>> 308: };
>> 
>> An issue with this allocator is that it doesn't call destructors on `free`. I think we should add this, or any future users may leak memory by mistake.
>
> Some more thoughts: It's not the allocator that should run the destructor, but the RBTree itself. It should probably enforce that the key is a trivial type also.

We now assert that the key is trivially destructible and the value's destructor is called when removing a node

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22360#discussion_r1908778181


More information about the hotspot-dev mailing list