This is the core of raxFree(): performs a depth-first scan of the * tree and releases all the nodes found. */
| 1221 | /* This is the core of raxFree(): performs a depth-first scan of the |
| 1222 | * tree and releases all the nodes found. */ |
| 1223 | void raxRecursiveFree(rax *rax, raxNode *n, void (*free_callback)(void*)) { |
| 1224 | debugnode("free traversing",n); |
| 1225 | int numchildren = n->iscompr ? 1 : n->size; |
| 1226 | raxNode **cp = raxNodeLastChildPtr(n); |
| 1227 | while(numchildren--) { |
| 1228 | raxNode *child; |
| 1229 | memcpy(&child,cp,sizeof(child)); |
| 1230 | raxRecursiveFree(rax,child,free_callback); |
| 1231 | cp--; |
| 1232 | } |
| 1233 | debugnode("free depth-first",n); |
| 1234 | if (free_callback && n->iskey && !n->isnull) |
| 1235 | free_callback(raxGetData(n)); |
| 1236 | rax_free(n); |
| 1237 | rax->numnodes--; |
| 1238 | } |
| 1239 | |
| 1240 | /* Free a whole radix tree, calling the specified callback in order to |
| 1241 | * free the auxiliary data. */ |
no test coverage detected