On 11/18/21 2:58 AM, Giovanni Mascellani wrote:
Hi,
On 18/11/21 05:09, Zebediah Figura (she/her) wrote:
I didn't notice this last time, but since IIUC rbtree entries can hold a pointer to the head of the list (much like linked list entries), this isn't safe. You'll need to individually allocate list heads.
It doesn't look so:
struct rb_entry { struct rb_entry *parent; struct rb_entry *left; struct rb_entry *right; unsigned int flags; };
struct rb_tree { rb_compare_func compare; struct rb_entry *root; };
The entries have pointers between themselves, but none of them points to the tree itself. Just the other way around. In other words, struct rb_tree already provides the level of indirection that you rightly say it is needed.
Eh, never mind, you're right, I thought the top-level entries had the tree as a parent, but they don't.