| 232 | /*:8*//*16:*/ |
| 233 | |
| 234 | int critbit0_delete(critbit0_tree*t,const char*u){ |
| 235 | const uint8*ubytes= (void*)u; |
| 236 | const size_t ulen= strlen(u); |
| 237 | uint8*p= t->root; |
| 238 | void**wherep= &t->root; |
| 239 | void**whereq= 0; |
| 240 | critbit0_node*q= 0; |
| 241 | int direction= 0; |
| 242 | |
| 243 | /*17:*/ |
| 244 | |
| 245 | if(!p)return 0; |
| 246 | |
| 247 | /*:17*/ |
| 248 | |
| 249 | /*18:*/ |
| 250 | |
| 251 | while(1&(intptr_t)p){ |
| 252 | whereq= wherep; |
| 253 | q= (void*)(p-1); |
| 254 | uint8 c= 0; |
| 255 | if(q->byte<ulen)c= ubytes[q->byte]; |
| 256 | direction= (1+(q->otherbits|c))>>8; |
| 257 | wherep= q->child+direction; |
| 258 | p= *wherep; |
| 259 | } |
| 260 | |
| 261 | /*:18*/ |
| 262 | |
| 263 | /*19:*/ |
| 264 | |
| 265 | if(0!=strcmp(u,(const char*)p))return 0; |
| 266 | #if 0 |
| 267 | free(p); |
| 268 | #endif |
| 269 | |
| 270 | /*:19*/ |
| 271 | |
| 272 | /*20:*/ |
| 273 | |
| 274 | if(!whereq){ |
| 275 | t->root= 0; |
| 276 | return 1; |
| 277 | } |
| 278 | |
| 279 | *whereq= q->child[1-direction]; |
| 280 | free(q); |
| 281 | allocated--; |
| 282 | /*:20*/ |
| 283 | |
| 284 | |
| 285 | return 1; |
| 286 | } |
| 287 | |
| 288 | /*:16*//*21:*/ |
| 289 | |