RCS file: /cvsroot/curl/curl/lib/splay.c,v
retrieving revision 1.3
diff -u -r1.3 splay.c
|
|
|
|
| 80 | 80 | else |
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | | l->larger = r->smaller = NULL; |
| 84 | 83 | |
| 85 | 84 | l->larger = t->smaller; /* assemble */ |
| 86 | 85 | r->smaller = t->larger; |
| … |
… |
|
| 114 | 113 | t->smaller = node; /* in the sub node for this same key, we use the |
| 115 | 114 | smaller pointer to point back to the master |
| 116 | 115 | node */ |
| | 116 | |
| 117 | 117 | t->key = KEY_NOTUSED; /* and we set the key in the sub node to NOTUSED |
| 118 | 118 | to quickly identify this node as a subnode */ |
| 119 | 119 | |
| … |
… |
|
| 270 | 270 | /* Key set to NOTUSED means it is a subnode within a 'same' linked list |
| 271 | 271 | and thus we can unlink it easily. The 'smaller' link of a subnode |
| 272 | 272 | links to the parent node. */ |
| | 273 | if (remove->smaller == NULL) |
| | 274 | return 3; |
| | 275 | |
| 273 | 276 | remove->smaller->same = remove->same; |
| 274 | 277 | if(remove->same) |
| 275 | 278 | remove->same->smaller = remove->smaller; |
| | 279 | |
| | 280 | /* Ensures that double-remove gets caught. */ |
| | 281 | remove->smaller = NULL; |
| | 282 | |
| 276 | 283 | /* voila, we're done! */ |
| 277 | 284 | *newroot = t; /* return the same root */ |
| 278 | 285 | return 0; |
| … |
… |
|
| 280 | 287 | |
| 281 | 288 | t = Curl_splay(remove->key, t); |
| 282 | 289 | |
| 283 | | /* First make sure that we got a root node witht he same key as the one we |
| 284 | | want to remove, as otherwise we might be trying to remove a node that |
| 285 | | isn't actually in the tree. */ |
| 286 | | if(t->key != remove->key) |
| | 290 | /* First make sure that we got the same root node as the one we want |
| | 291 | to remove, as otherwise we might be trying to remove a node that |
| | 292 | isn't actually in the tree. |
| | 293 | |
| | 294 | We cannot just compare the keys here as a double remove in quick |
| | 295 | succession of a node with key != KEY_NOTUSED && same != NULL |
| | 296 | could return the same key but a different node. */ |
| | 297 | if(t != remove) |
| 287 | 298 | return 2; |
| 288 | 299 | |
| 289 | 300 | /* Check if there is a list with identical sizes, as then we're trying to |