Amanieu / intrusive-rs

Intrusive collections for Rust
Apache License 2.0
400 stars 47 forks source link

Why is `parent_color` usize in RBTreeLink? #16

Closed Restioson closed 6 years ago

Restioson commented 6 years ago

Why does this have to be a usize? Couldn't it be a u8?

Amanieu commented 6 years ago

It holds the parent pointer, and puts the color in the lowest bit of the address. This is OK since the address is at least aligned by 2.

Restioson commented 6 years ago

Ah ok, I was wondering since it wasn't obvious that it also held a pointer to the parent. Closing.

By the way, thanks for such a high quality and speedy crate! I was able to achieve (in a simulation) 3GiB/s throughput of physical (mocked) memory allocation using the RBTree for buddy memory allocation. If you want, you can see the benchmarks here https://github.com/Restioson/buddy-allocator-workshop. Great work ❤️