Last active
March 13, 2019 04:56
-
-
Save santileortiz/08724683e74270efd3a5ac22788b694f to your computer and use it in GitHub Desktop.
Unexpected behavior of GTree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When using GTree I made the mistake of keeping pointers to keys and overwriting | |
them. I expected this would only affect the overwritten keys, and make lookups | |
for them return NULL. What actually happened was that other keys not related to | |
these became unaccessible. I am puzzled as to why this happened, it may be | |
interesting to dig inside GTree's implementation and see what's going on. | |
My guess is doing this breaks the sorted invariant of the tree, then things | |
will go crazy next time it tries to balance it, maybe for some reason it tries | |
to fix it by replacing existing keys?. Or, maybe the result of the string | |
comparison function does not really check for equallity, and instead has an | |
"else" clause that assumes keys to be sorted, then things compare as equal when | |
they ar not, causing some existing key to get replaced. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment