MCPcopy Create free account
hub / github.com/ElementsProject/lightning / critbit0_delete

Function critbit0_delete

ccan/ccan/strset/tools/cbspeed.c:234–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected