On May 11, 2006 11:49:37 AM -0700 Frank Cusack <fcusack@fcusack.com> wrote:
On May 11, 2006 12:57:33 PM -0400 Alan DeKok <aland@nitros9.org> wrote:
and the "const" should really be there. The trees are used in a multi-threaded environment, and the default red-black tree code assumes that the sentinel is writable. It's not.
After I added the "const", I caught and fixed odd threading bugs, where two threads would compete in their writes to the sentinel, which would result in problems.
I removed the const because the compiler complains about Sentinel being self-referential (.Left is not const but you are assigning it a const).
It seemed easier than casting each NIL to (rbnode_t *).
Oh, and since you use -Wcast-qual I was under the impression that casting wouldn't get rid of the compiler warning.
How would you write to the sentinel if it's const? Or do you mean that threads would write to it when they shouldn't.
-frank